To assign the total cost of the Order to one or more payment groups, use the addOrderAmountToPaymentGroup() and addRemainingOrderAmountToPaymentGroup methods in the OrderManager. These methods add PaymentGroupOrderRelationship objects (of type OrderAmount or OrderAmountRemaining, respectively) to the Order.
Example 1
This example assigns an order’s total cost to a single PaymentGroup. The order’s total cost is $20.90. You can account for the total cost of the Order by calling:
addRemainingOrderAmountToPaymentGroup()and passing in the required parameters.-- or --
addOrderAmountToPaymentGroup()and passing in the value 20.90 for the amount parameter.
The disadvantage to calling addOrderAmountToPaymentGroup() instead of addRemainingOrderAmountToPaymentGroup() is that if the order’s total amount increases above $20.90, then you must call removeOrderAmountFromPaymentGroup() and then call addOrderAmountToPaymentGroup() again and pass in the new amount.
Example 2
This example assigns an order’s total cost to more than one PaymentGroup. The order’s total cost is $20.90, and there are two payment groups in the Order. You want to assign $10.00 to the first PaymentGroup and $10.90 to the second PaymentGroup. Follow these steps to assign the amounts to the different payment groups:
Call
addOrderAmountToPaymentGroup()and pass in the firstPaymentGroupand 10.00 for the amount parameter.Call
addRemainingOrderAmountToPaymentGroup(), or calladdOrderAmountToPaymentGroup()and pass in the secondPaymentGroupand 10.90 for the amount parameter.
Accounting for an Order’s Total Cost
If the total cost of an Order is assigned to one or more payment groups, then during checkout the order’s total cost is accounted for according to the following rules:
If the
Ordercontains aPaymentGroupOrderRelationshipof typeOrderAmountRemaining, then the order’s total cost is accounted for regardless of whether or not theOrderhas other payment relationships. This is because a “remaining” relationship covers everything not accounted for by other payment relationships.If an
Ordercontains one or morePaymentGroupOrderRelationshipobjects of typeOrderAmount, then the sum of the amounts in the relationships must be equal to or greater than the total amount of theOrderto account for the order’s total cost. (The total amount of anOrderis the sum of itsCommerceItemcosts,ShippingGroupcosts, and tax.)

