Class OrderToPaymentRequestDTOServiceImpl
- All Implemented Interfaces:
OrderToPaymentRequestDTOService
Order
- PaymentTransaction
into a PaymentRequestDTO so that the gateway can create
the appropriate request for a specific transaction.- Author:
- Elbert Bautista (elbertbautista)
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FulfillmentGroupServiceprotected PaymentRequestDTOServiceprotected org.broadleafcommerce.common.persistence.PostLoaderDaostatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetName(org.broadleafcommerce.profile.core.domain.Address address) protected voidpopulateAddressInfo(org.broadleafcommerce.common.payment.dto.AddressDTO<org.broadleafcommerce.common.payment.dto.PaymentRequestDTO> dto, org.broadleafcommerce.profile.core.domain.Address address) voidpopulateBillTo(Order order, org.broadleafcommerce.common.payment.dto.PaymentRequestDTO requestDTO) Uses billing information on the Order to populate thePaymentRequestDTO.billTo()objectvoidpopulateCustomerInfo(Order order, org.broadleafcommerce.common.payment.dto.PaymentRequestDTO requestDTO) Uses customer information on the Order to populate thePaymentRequestDTO.customer()objectvoidpopulateDefaultLineItemsAndSubtotal(Order order, org.broadleafcommerce.common.payment.dto.PaymentRequestDTO requestDTO) IMPORTANT:voidpopulateShipTo(Order order, org.broadleafcommerce.common.payment.dto.PaymentRequestDTO requestDTO) Uses the first shippable fulfillment group to populate thePaymentRequestDTO.shipTo()objectvoidpopulateTotals(Order order, org.broadleafcommerce.common.payment.dto.PaymentRequestDTO requestDTO) Uses total information on the Order to populate thePaymentRequestDTO.transactionTotal(String)()}PaymentRequestDTO.taxTotal(String)()}PaymentRequestDTO.shippingTotal(String)()}PaymentRequestDTO.orderCurrencyCode(String)()}protected PaymentTransactionrefreshTransaction(PaymentTransaction paymentTransaction) org.broadleafcommerce.common.payment.dto.PaymentRequestDTOtranslateOrder(Order order) This translates an Order into a PaymentRequestDTO.org.broadleafcommerce.common.payment.dto.PaymentRequestDTOtranslatePaymentTransaction(org.broadleafcommerce.common.money.Money transactionAmount, PaymentTransaction paymentTransaction) Utilizes thePaymentTransaction.getAdditionalFields()map to populate necessary request parameters on the resultingPaymentRequestDTO.org.broadleafcommerce.common.payment.dto.PaymentRequestDTOtranslatePaymentTransaction(org.broadleafcommerce.common.money.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".
-
Field Details
-
ZERO_TOTAL
- See Also:
-
fgService
-
postLoaderDao
protected org.broadleafcommerce.common.persistence.PostLoaderDao postLoaderDao -
paymentRequestDTOService
-
-
Constructor Details
-
OrderToPaymentRequestDTOServiceImpl
public OrderToPaymentRequestDTOServiceImpl()
-
-
Method Details
-
translateOrder
Description copied from interface:OrderToPaymentRequestDTOServiceThis 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.- Specified by:
translateOrderin interfaceOrderToPaymentRequestDTOService- Parameters:
order- theOrderto be translated- Returns:
- a
PaymentRequestDTObased on the properties of an order.
-
translatePaymentTransaction
public org.broadleafcommerce.common.payment.dto.PaymentRequestDTO translatePaymentTransaction(org.broadleafcommerce.common.money.Money transactionAmount, PaymentTransaction paymentTransaction) Description copied from interface:OrderToPaymentRequestDTOServiceUtilizes 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.- Specified by:
translatePaymentTransactionin interfaceOrderToPaymentRequestDTOService- 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
public org.broadleafcommerce.common.payment.dto.PaymentRequestDTO translatePaymentTransaction(org.broadleafcommerce.common.money.Money transactionAmount, PaymentTransaction paymentTransaction, boolean autoCalculateFinalPaymentTotals) Description copied from interface:OrderToPaymentRequestDTOServiceImportant: 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...)- Specified by:
translatePaymentTransactionin interfaceOrderToPaymentRequestDTOService- Returns:
-
refreshTransaction
-
populateTotals
public void populateTotals(Order order, org.broadleafcommerce.common.payment.dto.PaymentRequestDTO requestDTO) Description copied from interface:OrderToPaymentRequestDTOServiceUses total information on the Order to populate thePaymentRequestDTO.transactionTotal(String)()}PaymentRequestDTO.taxTotal(String)()}PaymentRequestDTO.shippingTotal(String)()}PaymentRequestDTO.orderCurrencyCode(String)()}- Specified by:
populateTotalsin interfaceOrderToPaymentRequestDTOService- Parameters:
order- theOrderto get data fromrequestDTO- thePaymentRequestDTOthat should be populated
-
populateCustomerInfo
public void populateCustomerInfo(Order order, org.broadleafcommerce.common.payment.dto.PaymentRequestDTO requestDTO) Description copied from interface:OrderToPaymentRequestDTOServiceUses customer information on the Order to populate thePaymentRequestDTO.customer()object- Specified by:
populateCustomerInfoin interfaceOrderToPaymentRequestDTOService- Parameters:
order- theOrderto get data fromrequestDTO- thePaymentRequestDTOthat should be populated
-
populateShipTo
public void populateShipTo(Order order, org.broadleafcommerce.common.payment.dto.PaymentRequestDTO requestDTO) Uses the first shippable fulfillment group to populate thePaymentRequestDTO.shipTo()object- Specified by:
populateShipToin interfaceOrderToPaymentRequestDTOService- Parameters:
order- theOrderto get data fromrequestDTO- thePaymentRequestDTOthat should be populated
-
populateBillTo
public void populateBillTo(Order order, org.broadleafcommerce.common.payment.dto.PaymentRequestDTO requestDTO) Description copied from interface:OrderToPaymentRequestDTOServiceUses billing information on the Order to populate thePaymentRequestDTO.billTo()object- Specified by:
populateBillToin interfaceOrderToPaymentRequestDTOService- Parameters:
order- theOrderto get data fromrequestDTO- thePaymentRequestDTOthat should be populated
-
populateAddressInfo
protected void populateAddressInfo(org.broadleafcommerce.common.payment.dto.AddressDTO<org.broadleafcommerce.common.payment.dto.PaymentRequestDTO> dto, org.broadleafcommerce.profile.core.domain.Address address) -
getName
protected OrderToPaymentRequestDTOServiceImpl.NameResponse getName(org.broadleafcommerce.profile.core.domain.Address address) -
populateDefaultLineItemsAndSubtotal
public void populateDefaultLineItemsAndSubtotal(Order order, org.broadleafcommerce.common.payment.dto.PaymentRequestDTO requestDTO) IMPORTANT:If you would like to pass Line Item information to a payment gateway so that it shows up on the hosted site, you will need to override this method and construct line items to conform to the requirements of that particular gateway:
For Example: The Paypal Express Checkout NVP API validates that the order subtotal that you pass in, add up to the amount of the line items that you pass in. So, In that case you will need to take into account any additional fees, promotions, credits, gift cards, etc... that are applied to the payment and add them as additional line items with a negative amount when necessary.
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.
- Specified by:
populateDefaultLineItemsAndSubtotalin interfaceOrderToPaymentRequestDTOService- Parameters:
order-requestDTO-
-