Motorprise provides users the option to use multiple payment methods for processing their order. This feature is implemented in Motorprise beginning with checkout/payment_methods.jsp, which is linked to from billing.jsp. This page is used to gather a list of the user’s possible payment methods, before they are actually applied to specific portions of the order.

This feature again relies on the type of PaymentGroups that the user is authorized to use. If the user is authorized to use invoices, then she may enter multiple PO or requisition numbers. If the user is authorized to use credit cards, then she may use all those found in her Profile. Users first select a default PaymentGroup before proceeding to the split payment pages. All the order costs are initially applied to this default PaymentGroup. Users can then split portions of that cost into different PaymentGroups. We used checkout/SplitPaymentOrderDetails.jsp to let users split the PaymentGroups that will be applied to the entire order.

The PaymentGroupDroplet is used to provide the required helper objects and, based on the user’s authorization, to include the user’s credit cards in the PaymentGroupMapContainer. Any InvoiceRequest objects created on previous payment_methods.jsp are already in the session-scoped container. The following JSP on SplitPaymentOrderDetails.jsp ensures this initialization:

<%--
    The PaymentGroupDroplet initializes an OrderPaymentInfo object based on
    the value of the request parameter "init". CreditCard PaymentGroups are also
    initialized if the user is authorized to use them.
--%>
<dsp:droplet name="PaymentGroupDroplet">
   <dsp:param name="initOrderPayment" param="init"/>
   <dsp:param name="paymentGroupTypes" value="creditCard"/>
   <dsp:param name="initPaymentGroups" param="potentialPaymentTypes.creditCard"/>
   <dsp:oparam name="output">

Once initialization is complete, we present the user with a form to edit the payment information for the order. The OrderPaymentInfo helper objects hold the information that associates PaymentGroups in the PaymentGroupMapContainer to the Order by amount.

A similar page is checkout/SplitPaymentDetails.jsp. It works the same way as SplitPaymentOrderDetails.jsp, except that it enables the user to split the PaymentGroups across line items, shipping costs, and tax. The PaymentGroupDroplet creates a CommerceItemPaymentInfo object for each CommerceItem in the order, a ShippingGroupPaymentInfo object for each ShippingGroup in the Order, and a TaxPaymentInfo for the tax. The following JSP ensures this initialization:

<%--The PaymentGroupDroplet initializes the CommerceIdentifierPaymentInfo objects
    based on the value of the request parameter "init". CreditCard PaymentGroups
    are also initialized if the user is authorized to use them.
--%>

<dsp:droplet name="PaymentGroupDroplet">
   <dsp:param name="initItemPayment" param="init"/>
   <dsp:param name="initShippingPayment" param="init"/>
   <dsp:param name="initTaxPayment" param="init"/>
   <dsp:param name="paymentGroupTypes" value="creditCard"/>
   <dsp:param name="initPaymentGroups" param="potentialPaymentTypes.creditCard"/>
   <dsp:oparam name="output">

We create a form by iterating over the OrderPaymentInfo objects for the order. Initially, the PaymentGroupDroplet creates one OrderPaymentInfo object that associates the entire Order cost to the default PaymentGroup.

Each time the user splits a portion of the order using a different payment, a new OrderPaymentInfo object is added to the CommerceIdentifierPaymentInfoContainer.

The form permits the user to update the SplitAmount and SplitPaymentMethod property values of these objects, and to submit them by calling PaymentGroupFormHandler.splitPaymentInfo. This property associates the order costs with additional or different PaymentGroups than those provided by the PaymentGroupDroplet initialization.

We present the user with a form to edit all of these CommerceIdentifierPaymentInfo objects, which appear as line items that include a payment type and a payment amount. We first retrieve the CommerceItems, ShippingGroups, and the Order itself. For each of these we obtain the corresponding list of CommerceItemPaymentInfo objects. We iterate over each list and provide inputs to edit the items’ SplitAmount and SplitPaymentMethod property values.

As is the case with complex ShippingGroups, we encounter a complex set of form elements here. The PaymentGroupDroplet.CommerceIdentifierPaymentInfoContainer.CommerceIdentifierPaymentInfoMap bean property is a Map of CommerceIdentifierPaymentInfoLists. The value of the request parameter commerceItem.id is the dynamic key used to obtain the CommerceIdentifierPaymentInfoList that corresponds to the current CommerceItem in the outer ForEach iteration. In order to obtain a reference to a particular CommerceIdentifierPaymentInfo list, we set the PaymentGroupFormHandler.listId property with the list’s key. The list is then exposed via the PaymentGroupFormHandler.currentList property. We then iterate over the list and expose the splitAmount and splitPaymentMethod properties of each item, as referenced in a list by the index param.

Once the user is satisfied with the payment method associations, she may proceed with the purchase process by clicking Continue, which invokes the PaymentGroupFormHandler.applyPaymentGroups handler. The handler collects the information in the CommerceIdentifierPaymentInfo objects and adds the appropriate PaymentGroups to the Order, along with the necessary relationships to the CommerceItems in the order. For more information on the PaymentGroupFormHandler, see Checking Out Orders in the Configuring Purchase Process Services chapter of the ATG Commerce Programming Guide. The JSP to accomplish this is as follows:

<dsp:form action="split_payment.jsp" method="post">
<dsp:input bean="PaymentGroupFormHandler.applyPaymentGroupsSuccessURL" type=
   "hidden" value="IsEmptyCostCenters.jsp?link=split_payment.jsp"/>
<dsp:input bean="PaymentGroupFormHandler.applyPaymentGroups" type="submit"
   value="Continue"/>
</dsp:form>
 
loading table of contents...