@Service(value="blOrderToPaymentRequestDTOService") public class OrderToPaymentRequestDTOServiceImpl extends Object implements OrderToPaymentRequestDTOService
Order
- PaymentTransaction
into a PaymentRequestDTO so that the gateway can create
the appropriate request for a specific transaction.| Modifier and Type | Class and Description |
|---|---|
class |
OrderToPaymentRequestDTOServiceImpl.NameResponse |
| Modifier and Type | Field and Description |
|---|---|
protected FulfillmentGroupService |
fgService |
static String |
ZERO_TOTAL |
| Constructor and Description |
|---|
OrderToPaymentRequestDTOServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
protected OrderToPaymentRequestDTOServiceImpl.NameResponse |
getName(Address address) |
protected boolean |
orderContainsMultipleFinalPayments(Order order)
determine whether or not this order contains multiple final payments.
|
void |
populateBillTo(Order order,
PaymentRequestDTO requestDTO)
Uses billing information on the Order to populate the
PaymentRequestDTO.billTo() object |
void |
populateCustomerInfo(Order order,
PaymentRequestDTO requestDTO)
Uses customer information on the Order to populate the
PaymentRequestDTO.customer() object |
void |
populateDefaultLineItemsAndSubtotal(Order order,
PaymentRequestDTO requestDTO)
IMPORTANT:
|
void |
populateShipTo(Order order,
PaymentRequestDTO requestDTO)
Uses the first shippable fulfillment group to populate the
PaymentRequestDTO.shipTo() object |
void |
populateTotals(Order order,
PaymentRequestDTO requestDTO)
Uses total information on the Order to populate the
PaymentRequestDTO.transactionTotal(String)()}
PaymentRequestDTO.taxTotal(String)()}
PaymentRequestDTO.shippingTotal(String)()}
PaymentRequestDTO.orderCurrencyCode(String)()} |
protected boolean |
transactionIsDetachedCreditRequest(PaymentTransaction transaction)
determine whether or not this transaction is a detached credit request.
|
PaymentRequestDTO |
translateOrder(Order order)
This translates an Order into a PaymentRequestDTO.
|
PaymentRequestDTO |
translatePaymentTransaction(Money transactionAmount,
PaymentTransaction paymentTransaction)
Utilizes the
PaymentTransaction.getAdditionalFields() map to populate necessary request parameters on the
resulting PaymentRequestDTO. |
public static final String ZERO_TOTAL
protected FulfillmentGroupService fgService
public PaymentRequestDTO translateOrder(Order order)
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 PaymentRequestDTO will be Order.getTotalAfterAppliedPayments()
It assumes that all other payments (e.g. gift cards/account credit) have already
been applied to the Order.
translateOrder in interface OrderToPaymentRequestDTOServiceorder - the Order to be translatedPaymentRequestDTO based on the properties of an order.public PaymentRequestDTO translatePaymentTransaction(Money transactionAmount, PaymentTransaction paymentTransaction)
OrderToPaymentRequestDTOServicePaymentTransaction.getAdditionalFields() map to populate necessary request parameters on the
resulting PaymentRequestDTO. These additional fields are then used by the payment gateway to construct
additional requests. For example, an existing PaymentTransaction of
type PaymentTransactionType.AUTHORIZE might be passed into this method
in order for the gateway issue a "reverse auth" against this original transaction.
Important: As of 4.0.1-GA+ the transaction amount passed in will notValidateAndConfirmPaymentActivity and the
payment transaction passed in is of type PaymentTransactionType.UNCONFIRMED.
If it is an unconfirmed payment, 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...)translatePaymentTransaction in interface OrderToPaymentRequestDTOServicetransactionAmount - the amount that should be placed on PaymentRequestDTO.getTransactionTotal()paymentTransaction - the transaction whose additional fields should be placed on PaymentRequestDTO.getAdditionalFields()
for the gateway to usePaymentRequestDTO populated 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.https://github.com/BroadleafCommerce/BroadleafCommerce/issues/1423} for details.,
org.broadleafcommerce.core.checkout.service.workflow.ValidateAndConfirmPaymentActivity},
org.broadleafcommerce.core.checkout.service.workflow.ConfirmPaymentsRollbackHandler}protected boolean orderContainsMultipleFinalPayments(Order order)
order - protected boolean transactionIsDetachedCreditRequest(PaymentTransaction transaction)
transaction - public void populateTotals(Order order, PaymentRequestDTO requestDTO)
OrderToPaymentRequestDTOServicePaymentRequestDTO.transactionTotal(String)()}
PaymentRequestDTO.taxTotal(String)()}
PaymentRequestDTO.shippingTotal(String)()}
PaymentRequestDTO.orderCurrencyCode(String)()}populateTotals in interface OrderToPaymentRequestDTOServiceorder - the Order to get data fromrequestDTO - the PaymentRequestDTO that should be populatedpublic void populateCustomerInfo(Order order, PaymentRequestDTO requestDTO)
OrderToPaymentRequestDTOServicePaymentRequestDTO.customer() objectpopulateCustomerInfo in interface OrderToPaymentRequestDTOServiceorder - the Order to get data fromrequestDTO - the PaymentRequestDTO that should be populatedpublic void populateShipTo(Order order, PaymentRequestDTO requestDTO)
PaymentRequestDTO.shipTo() objectpopulateShipTo in interface OrderToPaymentRequestDTOServiceorder - the Order to get data fromrequestDTO - the PaymentRequestDTO that should be populatedFulfillmentGroupService#getFirstShippableFulfillmentGroup(Order)}public void populateBillTo(Order order, PaymentRequestDTO requestDTO)
OrderToPaymentRequestDTOServicePaymentRequestDTO.billTo() objectpopulateBillTo in interface OrderToPaymentRequestDTOServiceorder - the Order to get data fromrequestDTO - the PaymentRequestDTO that should be populatedprotected OrderToPaymentRequestDTOServiceImpl.NameResponse getName(Address address)
public void populateDefaultLineItemsAndSubtotal(Order order, PaymentRequestDTO requestDTO)
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.
populateDefaultLineItemsAndSubtotal in interface OrderToPaymentRequestDTOServiceorder - requestDTO - Copyright © 2016. All rights reserved.