When an order is saved in the database or the status of an order is changed (i.e. through the callback of a payment gateway), KonaKart instantiates a class defined by the property ORDER_INTEGRATION_CLASS. If this property isn't set, the class that is instantiated is com.konakart.bl.OrderIntegrationMgr. If you write a custom class it must implement the interface com.konakart.bl.OrderIntegrationMgrInterface which contains some methods:
/**
* Called just after an order has been saved. The order details are passed to the method so that
* all the information should be available in order to integrate with external systems.
*
* @param order
*/
public void saveOrder(OrderIf order);
/**
* Called just before an order has been saved. This method gives the opportunity to modify any
* detail of the order before it is saved. If null is returned, then no action is taken. If a
* non null Order is returned, then this is the order that will be saved.
*
* @param order
* @return Returns an order object which will be saved
*/
public OrderIf beforeSaveOrder(OrderIf order);
/**
* Called just after an order status change
*
* @param orderId
* @param currentStatus
* @param newStatus
*/
public void changeOrderStatus(int orderId, int currentStatus, int newStatus);
/**
* This method allows you to introduce a proprietary algorithm for creating the order number for
* an order just before the order is saved. It is called by the saveOrder() method.
* The value returned by this method populates the orderNumber attribute of the
* order when it is saved.
* If a null value is returned, then the order number of the order is left unchanged.
* If an exception is thrown, the exception will be also thrown by the saveOrder() method and
* the order will not be saved.
*
* @param order
* @return Return the order number for the new order
* @throws Exception
*/
public String createOrderNumber(OrderIf order) throws Exception;
/**
* This method allows you to generate a tracking number for an order just before the order is
* saved. It is called by the saveOrder() method. The value returned by this method
* populates the trackingNumber attribute of the order when it is saved.
* If a null value is returned, then the tracking number of the order is left unchanged.
* If an exception is thrown, the exception will be also thrown by the saveOrder() method and
* the order will not be saved.
*
* @param order
* @return Return the tracking number for the new order
* @throws Exception
*/
public String createTrackingNumber(OrderIf order) throws Exception;
/**
* Called just before a subscription is inserted. This method gives the opportunity to modify
* any detail of the subscription before it is inserted. If null is returned, then no action is
* taken. If a non null subscription is returned, then this is the subscription that will be
* saved.
*
* @param subscription
* @return Returns a Subscription
* @throws Exception
*/
public SubscriptionIf beforeInsertSubscription(SubscriptionIf subscription) throws Exception;
and more........
The state of an order may be changed manually through the Admin App. In this case KonaKart instantiates a class defined by the property ADMIN_ORDER_INTEGRATION_CLASS. If this property isn't set, the class that is instantiated is com.konakartadmin.bl.AdminOrderIntegrationMgr. If you write a custom class it must implement the interface com.konakartadmin.bl.AdminOrderIntegrationMgrInterface which contains the method:
/**
* Called just after an order status change
*
* @param orderId
* Id of the order
* @param currentStatus
* Current state of the order
* @param newStatus
* New state of the order
*/
public void changeOrderStatus(int orderId, int currentStatus, int newStatus);
/**
* This method may be customized in order to implement an algorithm that creates an RMA code for
* the order. The Administration Application will use the returned value (if not null) to
* automatically populate the RMA code entry field.
*
* @param orderId
* Id of the order
* @return Returns an RMA Code
*/
public String getRMACode(int orderId);
This mechanism is a useful generic way to interface KonaKart to external systems since the custom classes could write data to a database, call a web service or write data to a file etc.
The ORDER_INTEGRATION_CLASS and ADMIN_ORDER_INTEGRATION_CLASS properties can be edited in the Configuration>>Stock and Orders section of the Admin App.