Interface OrderToPaymentRequestDTOService
- All Known Implementing Classes:
OrderToPaymentRequestDTOServiceImpl
- Author:
- Elbert Bautista (elbertbautista)
-
Method Summary
Modifier and TypeMethodDescriptionvoidpopulateBillTo(Order order, PaymentRequestDTO requestDTO) Uses billing information on the Order to populate thePaymentRequestDTO.billTo()objectvoidpopulateCustomerInfo(Order order, PaymentRequestDTO requestDTO) Uses customer information on the Order to populate thePaymentRequestDTO.customer()objectvoidpopulateDefaultLineItemsAndSubtotal(Order order, PaymentRequestDTO requestDTO) Uses order information to populate various line item and subtotal information on the ordervoidpopulateShipTo(Order order, PaymentRequestDTO requestDTO) Uses the first shippable fulfillment group to populate thePaymentRequestDTO.shipTo()objectvoidpopulateTotals(Order order, PaymentRequestDTO requestDTO) Uses total information on the Order to populate thePaymentRequestDTO.transactionTotal(String)()}PaymentRequestDTO.taxTotal(String)()}PaymentRequestDTO.shippingTotal(String)()}PaymentRequestDTO.orderCurrencyCode(String)()}translateOrder(Order order) This translates an Order into a PaymentRequestDTO.translatePaymentTransaction(Money transactionAmount, PaymentTransaction paymentTransaction) Utilizes thePaymentTransaction.getAdditionalFields()map to populate necessary request parameters on the resultingPaymentRequestDTO.translatePaymentTransaction(Money transactionAmount, PaymentTransaction paymentTransaction, boolean autoCalculateFinalPaymentTotals) Important: As of 4.0.1-GA+, there is a requirement to automatically populate the transaction amount on the DTO only if coming from a "checkout payment flow".
-
Method Details
-
translateOrder
This translates an Order into a PaymentRequestDTO. This method assumes that the total transaction amount being sent to the gateway will be calculated from the "final payment" on the order. This means that the transaction amount for the returned
PaymentRequestDTOwill beOrder.getTotalAfterAppliedPayments()It assumes that all other payments (e.g. gift cards/account credit) have already been applied to theOrder.- Parameters:
order- theOrderto be translated- Returns:
- a
PaymentRequestDTObased on the properties of an order.
-
translatePaymentTransaction
PaymentRequestDTO translatePaymentTransaction(Money transactionAmount, PaymentTransaction paymentTransaction) Utilizes thePaymentTransaction.getAdditionalFields()map to populate necessary request parameters on the resultingPaymentRequestDTO. These additional fields are then used by the payment gateway to construct additional requests. For example, an existingPaymentTransactionof typePaymentTransactionType.AUTHORIZEmight be passed into this method in order for the gateway issue a "reverse auth" against this original transaction.- Parameters:
transactionAmount- the amount that should be placed onPaymentRequestDTO.getTransactionTotal()paymentTransaction- the transaction whose additional fields should be placed onPaymentRequestDTO.getAdditionalFields()for the gateway to use- Returns:
- a new
PaymentRequestDTOpopulated with the additional fields from paymentTransaction and the amount from transactionAmount OR override with final payment details on the order if coming in from a payment flow.
-
translatePaymentTransaction
PaymentRequestDTO translatePaymentTransaction(Money transactionAmount, PaymentTransaction paymentTransaction, boolean autoCalculateFinalPaymentTotals) Important: As of 4.0.1-GA+, there is a requirement to automatically populate the transaction amount on the DTO only if coming from a "checkout payment flow". That is, if you are invoking this method via theValidateAndConfirmPaymentActivityand the payment transaction passed in is of typePaymentTransactionType.UNCONFIRMED. If the totals need to be auto-calculated, the transaction total will be set from the "final payment" details that are coming off the order itself (along with other details like shipping/billing info etc...)- Parameters:
transactionAmount-paymentTransaction-autoCalculateFinalPaymentTotals-- Returns:
-
populateTotals
Uses total information on the Order to populate thePaymentRequestDTO.transactionTotal(String)()}PaymentRequestDTO.taxTotal(String)()}PaymentRequestDTO.shippingTotal(String)()}PaymentRequestDTO.orderCurrencyCode(String)()}- Parameters:
order- theOrderto get data fromrequestDTO- thePaymentRequestDTOthat should be populated
-
populateCustomerInfo
Uses customer information on the Order to populate thePaymentRequestDTO.customer()object- Parameters:
order- theOrderto get data fromrequestDTO- thePaymentRequestDTOthat should be populated
-
populateShipTo
Uses the first shippable fulfillment group to populate thePaymentRequestDTO.shipTo()object- Parameters:
order- theOrderto get data fromrequestDTO- thePaymentRequestDTOthat should be populated
-
populateBillTo
Uses billing information on the Order to populate thePaymentRequestDTO.billTo()object- Parameters:
order- theOrderto get data fromrequestDTO- thePaymentRequestDTOthat should be populated
-
populateDefaultLineItemsAndSubtotal
Uses order information to populate various line item and subtotal information on the order
IMPORTANT: Each gateway that accepts line item information may require you to construct this differently. Please consult the module documentation on how it should be properly constructed.
In this default implementation, just the subtotal is set, without any line item details.
- Parameters:
order- theOrderto get data fromrequestDTO- thePaymentRequestDTOthat should be populated
-