Chapter 15. Payment, Shipping and OrderTotal Modules

Table of Contents

Module Types
Payment Modules
Shipping Modules
Order Total Modules
Other Modules
How to Create a Payment Module
Introduction
Study the "KonaPay" APIs
Choose which Interface Type you want for your users
Sign up for a Test Account with "KonaPay"
Determine which of the existing payment modules is the closest match
Copy the files of the closest match as the starting point
Define the configuration parameters
Understanding the Configuration Options
Add the "KonaPay" gateway to the Admin App
Implement the PaymentInterface
NameValue[] Parameters
Implement the Action code
Save IPN details
Save the gateway response to a file
Send payment confirmation email
Struts mapping
Build, Deploy and Test
How to Create a Promotion Module
Determine which of the existing Promotion modules is the closest match
Copy the files of the closest match as the starting point
Define the configuration parameters
Add the new promotion module to the Admin App
Build, Deploy and Test

Module Types

KonaKart has a flexible plug-in architecture to support the addition of modules for "payment", "shipping", "order-totals" and "others".

Payment Modules

Payment modules shipped with KonaKart are installed and configured through the Administration Application.

If you wish to add a new payment gateway and are not a programmer, please contact us. If you are a Java programmer, it is possible for you to add your own module by following the examples we provide in the package. There is a detailed guide below.

The best approach is to learn by example. We supply all of our supported modules in source code format. They can be found under the KonaKart/custom/modules/src/com/konakart/bl/modules/payment directory. All payment modules should extend com.konakart.bl.modules.payment.BasePaymentModule and implement com.konakart.bl.modules.payment.PaymentInterface.

In order to determine which Payment Modules are installed, the KonaKart engine reads the "MODULE_PAYMENT_INSTALLED" configuration property which should contain a semicolon delimited list of payment modules installed. For backwards compatibility reasons, the property may contain a list of names with a php extension (i.e. cc.php;cod.php). KonaKart ignores the extension. Let's say that you introduce a new module called "MyModule". In this case, KonaKart will look for a class called MyModule.class in the package "com.konakart.bl.modules.payment.mymodule". Note that the package name is always the class name converted to lower case.

The interface that the payment module implements is relatively simple . The main method is called getPaymentDetails(Order order, PaymentInfo info) . The module is passed in the Order object and a PaymentInfo object . The PaymentInfo object contains details on zone information so that the module can be disabled if the delivery address isn't within a zone. It also contains details used mainly for IPN (Instant Payment Notification) such as the host and port details for the return notification and a secret key that can be used to validate the return notification. The order object contains all details about the order, some of which, may be required. In the case of the PayPal example, the final piece of the puzzle is contained in a Struts action class called com.konakart.actions.ipn.PayPalAction. This action is called by PayPal in order to return the status of the payment. When received, the action class may change the state of the order as well as updating the inventory.

Admin App Payment Modules

In some cases it may be necessary to communicate with the payment gateway after the purchase has been made by the customer using the storefront application. One example is when the credit card transaction is executed only after the goods have been shipped. Another example is recurring billing.

The Admin App has an API call callPaymentModule which may be used for making any type of transaction on the payment gateway. When the call is made, the full class name of the payment module object is passed, along with a PaymentOptions object containing all of the required data such as the order id and credit card details (if required).


    PaymentOptions options = new PaymentOptions();
    options.setOrderId(order.getId());
    options.setAction(0);
    NameValue[] retArray = getAdminModulesMgr().callPaymentModule(
            "com.konakartadmin.modules.payment.authorizenet.AdminPayment", options);


An example of the AdminPayment class is provided for AuthorizeNet. It must implement the com.konakartadmin.modules.AdminPaymentIf interface and by extending com.konakartadmin.modules.AdminBasePayment it inherits useful methods for sending the data to the payment gateway. The source code of all of these classes is supplied.

Shipping Modules

Shipping modules shipped with KonaKart are installed and configured through the Administration Application.

If you wish to add a new shipping module and are not a programmer, please contact us. If you are a Java programmer, it is possible for you to add your own module by following the examples we provide in the package. The best approach is to learn by example. We supply a few examples in source code format:

  • com.konakart.bl.modules.shipping.digitaldownload.DigitalDownload.java - If you sell digital download products in your store, then you should install this module.

  • com.konakart.bl.modules.shipping.fedex.Fedex.java - A FedEx shipping module

  • com.konakart.bl.modules.shipping.flat.Flat.java - A flat rate

  • com.konakart.bl.modules.shipping.free.Free.java - You should install this module to provide free shipping.

  • com.konakart.bl.modules.shipping.freeproduct.FreeProduct.java - If you have one or more products that have been configured for free shipping, then you should install this module.

  • com.konakart.bl.modules.shipping.item.Item.java - A rate per item

  • com.konakart.bl.modules.shipping.table.Table.java - This shipping module implements a rate per order weight or a rate based on the total cost.

  • com.konakart.bl.modules.shipping.ups.Ups.java - UPS shipping module.

  • com.konakart.bl.modules.shipping.zones.Zones.java - This shipping module implements a rate per item weight per zone.

In order to determine which Shipping Modules are installed, the KonaKart engine reads the "MODULE_SHIPPING_INSTALLED" configuration property which should contain a semicolon delimited list of shipping modules installed. For backwards compatibility reasons, the property may contain a list of names with a php extension (i.e. flat.php;item.php;table.php). KonaKart ignores the extension. Let's say that you introduce a new module called "MyModule". In this case, KonaKart will look for a class called MyModule.class in the package "com.konakart.bl.modules.shipping.mymodule". Note that the package name is always the class name converted to lower case.

The interface that the shipping module implements is relatively simple . The main method is called getQuote(Order order, ShippingInfo info) . The module is passed in the Order object and a ShippingInfo object . The ShippingInfo object contains details on zone information so that the module can be disabled if the delivery address isn't within a zone. It also contains information about the number of packages and their weight etc so that the shipping cost can be calculated . The order object contains all details about the order, some of which, may be required.

An alternative approach is to contact us with details of the Shipping Module that you would like to integrate with KonaKart so that we can create the module for you.

Configuring Free Shipping

From version 2.2.3.0, free shipping can be set on a product by product basis. To set free shipping for a product, you must navigate to the Details tab of the Edit Product panel in the Admin App. There you must change the product type to "Physical Product - Free Shipping". In order for this mechanism to function correctly, you must install the Shipping Module called "FreeProduct". This module will return a shipping quote of zero if it detects that the physical products within the order all have free shipping.

Free shipping for all products can be configured in the Administration Application in the section Modules>>Order Totals by selecting the Shipping Module.

You may allow free shipping by setting the Allow Free Shipping value to "true" . In order to not show the shipping cost of zero on the order you must set Display Shipping to "false". Free shipping can be made conditional for orders over a certain amount or just for a combination of national / international orders.

The text that you display on the screen in the area that you would normally select a shipping method, is defined in WEB-INF\classes\com\konakart\bl\modules\shipping\Shipping_xx.properties. This can be set to e.g. "Free shipping for orders over $50", "Free Shipping", "No Shipping" etc.

Note that in order to completely remove shipping from the checkout process, you will need to make modifications to the checkout process (i.e. JSPs and Struts Actions).

Configuring the Zones Shipping Module

The Zones Shipping Module allows you implement shipping rates based on the weight of the shipment, for different countries. The module can be installed and configured through the Admin App. The number of different shipping zones has to be decided before running the Admin App. It is set in the properties file:

/webapps/konakartadmin/WEB-INF/classes/com/konakartadmin/modules/shipping/zones/Zones.properties

by editing the section:


# Set this to the number of zones you require.
MODULE_SHIPPING_ZONES_NUMBER_OF_ZONES=1

The Admin App uses the above information to create a number of entry fields called "Zone 1 Countries", " Zone 1 Shipping Table", "Zone 1 Handling Fee", "Zone 2 Countries", Zone 2 Shipping Table" etc. depending on how many shipping zones are required.

For each shipping zone you must enter data in :

  • Zone X Countries

    Contains a comma separated list of two character ISO country codes that are part of a shipping zone (i.e. US, CA for USA and Canada)

  • Zone X Weight Charges

    Contains shipping rates to shipping zone destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 cost 8.50 for destinations in this Zone. Weights greater than 3 but less than or equal to 7, cost 10.50 for destinations in this zone.

  • Zone X Handling Fee

    Handling Fee for this shipping zone

Order Total Modules

Order Total modules shipped with KonaKart are installed and configured through the Administration Application.

If you wish to add a new order total module and are not a programmer, please contact us. If you are a Java programmer, it is possible for you to add your own module by following the examples we provide in the package.

The best approach is to learn by example. We supply the source code for all of the examples that are part of an installation. These include:

  • com.konakart.bl.modules.ordertotal.productdiscount.ProductDiscount.java - Discount for individual products

  • com.konakart.bl.modules.ordertotal.shipping.Shipping.java - Displays the shipping cost of the order

  • com.konakart.bl.modules.ordertotal.subtotal.Subtotal.java - Calculates the subtotal of the order

  • com.konakart.bl.modules.ordertotal.tax.Tax.java - Calculates the tax of the order

  • com.konakart.bl.modules.ordertotal.total.Total.java - Calculates the total of the order

  • com.konakart.bl.modules.ordertotal.totaldiscount.TotalDiscount.java - Discount on the total of the order

In order to determine which Order Total Modules are installed, the KonaKart engine reads the "MODULE_ORDER_TOTAL_INSTALLED" configuration property which should contain a semicolon delimited list of order total modules installed. For backwards compatibility reasons, the property may contain a list of names with a php extension (i.e. ot_subtotal.php;ot_tax.php;ot_shipping.php). KonaKart ignores the extension. Let's say that you introduce a new module called "MyModule". In this case, KonaKart will look for a class called MyModule.class in the package "com.konakart.bl.modules.ordertotal.mymodule". Note that the package name is always the class name converted to lower case.

The interface that the order total module implements is relatively simple . The main method is called getOrderTotal(Order order, boolean dispPriceWithTax, Locale locale) . The module is passed in the Order object which contains all details about the order, some of which, may be required.

An alternative approach is to contact us with details of the Order Total Module that you would like to integrate with KonaKart so that we can create the module for you.

Other Modules

Other modules shipped with KonaKart are installed and configured through the Administration Application.

If you wish to add a new other module and are not a programmer, please contact us. If you are a Java programmer, it is possible for you to add your own module by following the examples we provide in the package. The best approach is to learn by example. We supply a few examples in source code format:

  • com.konakart.bl.modules.others.captcha.Captcha.java - If you want to use Google reCaptcha in your store, then you should install this module. You find more at https://www.konakart.com/docs/GoogleReCaptchaService.html

In order to determine which Other Modules are installed, the KonaKart engine reads the "MODULE_OTHERS_INSTALLED" configuration property which should contain a semicolon delimited list of other modules installed. For backwards compatibility reasons, the property may contain a list of names with a php extension (i.e. flat.php;item.php;table.php). KonaKart ignores the extension. Let's say that you introduce a new module called "MyModule". In this case, KonaKart will look for a class called MyModule.class in the package "com.konakart.bl.modules.others.mymodule". Note that the package name is always the class name converted to lower case.

The interface that the other module implements is relatively simple . The main method is called validateCaptcha(CaptchaInputIf captchaInfo) . The module is passed in a CaptchaInput object . The CaptchaInput object contains details on captcha information so that the module can send captcha information to Google Server for validation.

An alternative approach is to contact us with details of the Other Module that you would like to integrate with KonaKart so that we can create the module for you.

Configuring the Captcha Module

The Captcha Module allows you to validate reCaptcha request against a Google ReCaptcha API. The module can be installed and configured through the Admin App.

You must enter validation secret to access to Google reCaptcha API and request url where validation input has to be sent for validation.