Customizing the business flow for payment processing

If the business flow provided by payment rules does not meet your business needs, you can customize the business flow used for payment processing.


  1. Identify your business scenario.
    In the business scenario determine which payment rules payment event task commands will be called. By default, the following task commands are called:
    • PrimePaymentCmd is called at Order Capture
    • ReservePaymentCmd is called at ReleaseToFulfillment
    • FinalizePaymentCmd is called at shipment confirmation
    If necessary, you can customize these task commands.
  2. Identify your business requirements for refund.
    By default, when a return is submitted the PrimeRefundCmd is called to create refund instruction. A single refund instruction per return is supported. FinalizeRefundCmd is called when the return is being closed and credited by the ReturnCreditAndCloseScanCmd scheduler job. To support other features, customize these refund related task commands.

Typical customization business scenarios

Many sites use WebSphere Commerce as the order capture system. The order is fulfilled and managed by an ERP, or order management system. The following list describes a typical scenario:
  • An order is captured by WebSphere Commerce. When the order is submitted, payment is authorized with order total amount. Then order is transferred to the external system.
  • After the order is fulfilled by the external order management system, a shipment confirmation message is passed back to WebSphere Commerce to capture payment for the shipped order items in this package.
  1. At order submission, the ProcessOrderCmdImpl command calls PrimePaymentCmd to process payment since the order total amount needs to be processed. Customize the getInitialAmount() method of the ProcessOrderCmdImpl command to get the total amount of this order.
  2. When the shipment confirmation is received by WebSphere Commerce, the order related information is updated in the WebSphere Commerce database. The payment of order items to be shipped needs to be captured at this phase.
    1. You should have a command to update order related information in WebSphere Commerce.
    2. In this command, call ReservePaymentCmd and FinalizePaymentCmd to capture payment for this order to be shipped.
      1. Call ReservePaymentCmd to process the ReservePayment payment event by using the following sample code.
        ReservePaymentCmd cmd = (ReservePaymentCmd)CommandFactory.createCommand(ReservePaymentCmd.NAME,storeId);
        In this sample code, shipmentList is a HashMap containing all order items to ship at this time, where the key is the shipment ID, and the value is the total amount of the shipment. For sites using the ATP inventory system, the shipment ID can be the release ID; for Non-ATP inventory, the shipment ID can be any identifier of this shipment. Also, dShipmentTotal is the total amount of those shipped order items previously of this order adding the total amount of order items to ship this time.
      2. Immediately after, FinalizePaymentCmd is called at the same caller for each shipment, respectively by using the sample code as follows:
        FinalizePaymentCmd cmd = 
           (FinalizePaymentCmd) CommandFactory.createCommand(FinalizePaymentCmd.NAME, storeId); 
        In this sample code, shipmentId corresponds to the identifier of this shipment used in the ReservePaymentCmd command above. Also, shipmentAmount is the total amount of this shipment.
    3. If you support multiple shipments and perform payment deposits by shipment, there will be multiple payment authorizations against one payment method. You can configure WebSphere Commerce to select the appropriate payment against which to perform the payment deposit action for the current shipment. This reduces transactions, and may reduce unnecessary charges for use of the payment network. To configure WebSphere Commerce to select payments for the current shipment, register the implementation class of DetermineSortedPaymentsCmd, which builds a relationship between shipments and payment actions.
      Register the DetermineSortedPaymentsCmdImpl task command using an SQL statement similar to the following example: