Payment in the fulfillment framework can be handled in two ways. The value of OrderFulfiller.settleOnFirstShipment determines how payment is handled:
If
settleOnFirstShipmentis true, all of the payment groups are settled after the first shipping group ships.If
settleOnFirstShipmentis false, all of the payment groups are settled after the last shipping group ships.
You can also configure the fulfillment framework to charge each shipping group to a different credit card at the time of shipment. There are two methods in the system that can be overwritten to facilitate this behavior:
OrderFulfillmentTools.isOrderSettleableThis method is called each time the
OrderFulfilleris notified that a shipping group has been shipped. (This notification occurs through aModifyOrderNotificationmessage that contains aGenericUpdateon the state of the shipping group. The new value isPENDING_SHIPMENT.)After the
OrderFulfillerreceives the notification, it callsOrderFulfillmentTools.isOrderSettleable. If this method returns true, thenOrderFulfiller.settleOrderis called. To configure the fulfillment framework to charge each shipping group to a different credit card at the time of shipment, have this method check if there is aPaymentGroupspecific to this shipping group. If there is, return true. It should also return true if allShippingGroupshave shipped.OrderFulfiller.settleOrderBy default, this method settles all
PaymentGroupsin the order. To pay for each shipping group as it ships, this method should settle eachPaymentGroupthat is notSETTLEDand refers to aShippingGroupthat has shipped.This method should also check if all shipping groups have shipped. If they have, than any other
PaymentGroupsthat have not settled, should be settled. Settling aPaymentGroupmost likely will involve using thePaymentManager.
To facilitate payment by shipping group as each shipping group is shipped, your system must create the appropriate PaymentGroupRelationship objects. To pay for each shipping group separately (and the items that appear in each shipping group), you will probably create each of these PaymentGroupRelationship objects yourself. When a user creates an order, the default behavior is for the order to include one PaymentGroup with one PaymentGroupOrderRelationship that accounts for the cost of the entire order. You might want to create a PaymentGroupCommerceItemRelationship for each item in the order, and a PaymentGroupShippingGroupRelationship for each shipping group in the order. It depends on your business rules.
For more information on payment groups, see the Creating Payment Groups section. For more information on the payment manager, see the Processing Payment of Orders section.

