Class DefaultPaymentTransactionExecutionService
- All Implemented Interfaces:
PaymentTransactionExecutionService
PaymentSummaries in the context of a checkout submission.- Author:
- Chris Kittrell (ckittrell)
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultPaymentTransactionExecutionService(PaymentTransactionExecutionProvider transactionExecutionProvider, PaymentProvider<PaymentSummary> paymentProvider, CartOperationCheckoutProperties properties, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected TransactionExecutionRequestbuildTransactionExecutionRequest(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull PaymentSummary paymentSummary, @NonNull String requestId, String securityCode) Builds aTransactionExecutionRequestto execute a transaction against the providedPaymentSummary.protected List<PaymentTransactionFailureDetail>buildTransactionFailureDetails(@NonNull TransactionExecutionResponse response) Builds a list ofPaymentTransactionFailureDetailsbased on theTransactionExecutionResponsethat was returned from PaymentTransactionServices.protected CheckoutProcessDtoclaimTransactionsForRequest(@NonNull CheckoutProcessDto processDto, @NonNull PaymentSummary paymentSummary, @NonNull String checkoutTransactionType, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) executeCartPaymentTransactions(@NonNull CheckoutProcessDto processDto, @NonNull Map<String, String> securityCodes, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Executes set of payment transactions against the cart'sPaymentSummaries.protected CheckoutProcessDtoexecutePaymentTransaction(@NonNull CheckoutProcessDto processDto, @NonNull PaymentSummary paymentSummary, String securityCode, @NonNull String checkoutTransactionType, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Executes a payment transaction against the providedPaymentSummary.protected TransactionExecutionResponseexecutePaymentTransaction(@NonNull String checkoutTransactionType, @NonNull PaymentSummary paymentSummary, @NonNull TransactionExecutionRequest request, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Executes a payment transaction based on the given checkout transaction type against the givenPaymentSummary.protected StringgetApplicationIdFromContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected StringgetCheckoutTransactionType(@NonNull String gatewayType, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Based on the providedPaymentGatewayType, determine whichTransactionTypeshould be used to execute the payment stage of the checkout.Deprecated.protected PaymentPriorityStrategyprotected PaymentProvider<PaymentSummary>protected PaymentTransactionExecutionProviderDeprecated.since 1.7.6, in favor of existingtransactionExecutionProviderprotected CartOperationCheckoutPropertiesprotected StringgetTenantIdFromContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransactionExecutionProviderprotected com.broadleafcommerce.common.extension.TypeFactoryprotected CheckoutProcessDtolookup3DSTransactionResults(@NonNull CheckoutProcessDto processDto, @NonNull PaymentSummary paymentSummary, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected booleanpaymentHasCheckoutAmountAwaitingResult(@NonNull PaymentSummary paymentSummary, @NonNull String checkoutTransactionType) Determines if the givenPaymentSummaryhas any amount awaiting result based on the given checkout transaction type.voidsetCreditAccountTransactionExecutionProvider(CreditAccountTransactionExecutionProvider creditAccountTransactionExecutionProvider) Deprecated.since 1.8.1, no longer used as store credit balance validation is moved toCartPaymentMethodValidationActivityvoidsetPaymentPriorityStrategy(PaymentPriorityStrategy paymentPriorityStrategy) voidsetPaymentTransactionExecutionProvider(PaymentTransactionExecutionProvider paymentTransactionExecutionProvider) Deprecated.since 1.7.6, in favor of existingtransactionExecutionProviderprotected booleanshouldClaimTransactionsForRequest(@NonNull PaymentSummary paymentSummary, @NonNull String checkoutTransactionType) protected booleanshouldExecutePaymentTransaction(@NonNull PaymentSummary paymentSummary, @NonNull String checkoutTransactionType) Determine whether to execute a transaction for this payment.protected booleanshouldLookup3DSTransactionResults(@NonNull PaymentSummary paymentSummary, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected List<PaymentSummary>sortPayments(@NonNull List<PaymentSummary> payments, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given a list ofPaymentSummaries, sorts them in order of which should be executed first based on thePaymentSummary.getGatewayType().protected List<PaymentSummary>sortPayments(List<PaymentSummary> payments) Deprecated.since 1.7.2, in favor ofsortPayments(List, ContextInfo)
-
Constructor Details
-
DefaultPaymentTransactionExecutionService
public DefaultPaymentTransactionExecutionService(PaymentTransactionExecutionProvider transactionExecutionProvider, PaymentProvider<PaymentSummary> paymentProvider, CartOperationCheckoutProperties properties, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
executeCartPaymentTransactions
public CheckoutProcessDto executeCartPaymentTransactions(@NonNull @NonNull CheckoutProcessDto processDto, @NonNull @NonNull Map<String, String> securityCodes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PaymentTransactionExecutionServiceExecutes set of payment transactions against the cart'sPaymentSummaries.- Specified by:
executeCartPaymentTransactionsin interfacePaymentTransactionExecutionService- Parameters:
processDto- TheCheckoutProcessDtothat we're attempting to checkout with and contains the relatedPaymentSummariessecurityCodes- The map of card security codes keyed by payment id for processing saved paymentscontextInfo- The context of the user's request.- Returns:
- The most up-to-date
CheckoutProcessDtofollowing the execution of the transaction
-
sortPayments
protected List<PaymentSummary> sortPayments(@NonNull @NonNull List<PaymentSummary> payments, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given a list ofPaymentSummaries, sorts them in order of which should be executed first based on thePaymentSummary.getGatewayType().This is used to order the cart's payments to produce the most favorable conditions when executing transactions against the payment, and primarily meant to help mitigate the challenges of multi-payment scenarios.
For example, if you have a payment method whose transactions are very challenging to reverse (in the case of a checkout failure), then it's best to order that payment last. If the
PaymentTransactionExecutionActivityis the last activity in the workflow and the payment with the challenging reversal is processed last, then the reversal will actually never be needed. Instead, either this payment's transaction will pass and the checkout completes, or the transaction fails and only the workflow's previously completed work may need to be rolled back.- Parameters:
payments- The un-ordered list of cart paymentscontextInfo- Context information surrounding sandboxing and multitenant state- Returns:
- The sorted list of cart payments
-
sortPayments
Deprecated.since 1.7.2, in favor ofsortPayments(List, ContextInfo)Hook used to order the cart's payments to produce the most favorable conditions when executing transactions against the payment. This is primarily meant to help mitigate the challenges of multi-payment scenarios. For example, if you have a payment method whose transactions are very challenging to roll back (in the case of a checkout failure), then it's best to order that payment last. If thePaymentTransactionExecutionActivityis the last activity in the workflow and the payment with the challenging rollback is processed last, then the rollback will actually never occur. Instead, either this payment's transaction will pass and the checkout completes, or the transaction fails and only previously completed work may need to be rolled back.- Parameters:
payments- The un-ordered list of cart payments- Returns:
- The sorted list of cart payments
-
getCheckoutTransactionType
protected String getCheckoutTransactionType(@NonNull @NonNull String gatewayType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Based on the providedPaymentGatewayType, determine whichTransactionTypeshould be used to execute the payment stage of the checkout.- Parameters:
gatewayType- The payment gateway's unique identifier that should be used to lookup the desired transaction type- Returns:
- The desired transaction type for the gateway
-
getApplicationIdFromContext
@Nullable protected String getApplicationIdFromContext(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getTenantIdFromContext
@Nullable protected String getTenantIdFromContext(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
shouldLookup3DSTransactionResults
protected boolean shouldLookup3DSTransactionResults(@NonNull @NonNull PaymentSummary paymentSummary, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
lookup3DSTransactionResults
protected CheckoutProcessDto lookup3DSTransactionResults(@NonNull @NonNull CheckoutProcessDto processDto, @NonNull @NonNull PaymentSummary paymentSummary, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
shouldExecutePaymentTransaction
protected boolean shouldExecutePaymentTransaction(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull String checkoutTransactionType) Determine whether to execute a transaction for this payment.- Parameters:
paymentSummary- the payment summary to be evaluatedcheckoutTransactionType- The type of transaction that is to be executed.- Returns:
- true if a transaction should be executed against this payment, false otherwise
-
executePaymentTransaction
protected CheckoutProcessDto executePaymentTransaction(@NonNull @NonNull CheckoutProcessDto processDto, @NonNull @NonNull PaymentSummary paymentSummary, @Nullable String securityCode, @NonNull @NonNull String checkoutTransactionType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Executes a payment transaction against the providedPaymentSummary.- Parameters:
processDto- TheCheckoutProcessDtoused to execute the paymentspaymentSummary- ThePaymentSummaryof the payment that will be acted upon by the transaction.securityCode- The payment method security code that may be required to execute the transaction.checkoutTransactionType- The type of transaction that is to be executed.contextInfo- The context of the user's request.- Returns:
- The most up-to-date cart following the execution of the transaction
- Throws:
PaymentTransactionFailureException- if the transaction was not successfully executed, either due to a transaction failure or an unexpected exception.
-
executePaymentTransaction
protected TransactionExecutionResponse executePaymentTransaction(@NonNull @NonNull String checkoutTransactionType, @NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull TransactionExecutionRequest request, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws UnsupportedOperationException Executes a payment transaction based on the given checkout transaction type against the givenPaymentSummary.- Parameters:
checkoutTransactionType- the type of transaction that is to be executedpaymentSummary- thePaymentSummaryto execute the transaction againstrequest- theTransactionExecutionRequestto executelockToken- the token that owns the payment lockcontextInfo- the context of the user's request- Returns:
- a
TransactionExecutionResponserepresenting the result of the transaction execution - Throws:
UnsupportedOperationException- if the given checkout transaction type is not supported
-
buildTransactionExecutionRequest
protected TransactionExecutionRequest buildTransactionExecutionRequest(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull String requestId, @Nullable String securityCode) Builds aTransactionExecutionRequestto execute a transaction against the providedPaymentSummary.- Parameters:
cart- The cart that is being checked out & that owns the relatedPaymentSummary.paymentSummary- ThePaymentSummaryof the payment that will be acted upon by executing a transaction.requestId- The id representing this request to checkout.securityCode- The payment method security code that may be required to execute the transaction.- Returns:
- A
TransactionExecutionRequestbased on the providedPaymentSummary.
-
buildTransactionFailureDetails
protected List<PaymentTransactionFailureDetail> buildTransactionFailureDetails(@NonNull @NonNull TransactionExecutionResponse response) Builds a list ofPaymentTransactionFailureDetailsbased on theTransactionExecutionResponsethat was returned from PaymentTransactionServices.- Parameters:
response- TheTransactionExecutionResponsereturned from PaymentTransaction from PaymentTransactionServices.- Returns:
- a list of
PaymentTransactionFailureDetailsbased on theTransactionExecutionResponsethat was returned from PaymentTransactionServices.
-
shouldClaimTransactionsForRequest
protected boolean shouldClaimTransactionsForRequest(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull String checkoutTransactionType) -
claimTransactionsForRequest
protected CheckoutProcessDto claimTransactionsForRequest(@NonNull @NonNull CheckoutProcessDto processDto, @NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull String checkoutTransactionType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
paymentHasCheckoutAmountAwaitingResult
protected boolean paymentHasCheckoutAmountAwaitingResult(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull String checkoutTransactionType) Determines if the givenPaymentSummaryhas any amount awaiting result based on the given checkout transaction type.- Parameters:
paymentSummary- thePaymentSummaryto check againstcheckoutTransactionType- the checkout transaction type for this payment- Returns:
- true if the given
PaymentSummaryhas any amount awaiting result, otherwise false
-
getTransactionExecutionProvider
-
getPaymentProvider
-
getProperties
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getPaymentPriorityStrategy
-
setPaymentPriorityStrategy
-
getPaymentTransactionExecutionProvider
Deprecated.since 1.7.6, in favor of existingtransactionExecutionProvider -
setPaymentTransactionExecutionProvider
@Deprecated @Autowired public void setPaymentTransactionExecutionProvider(PaymentTransactionExecutionProvider paymentTransactionExecutionProvider) Deprecated.since 1.7.6, in favor of existingtransactionExecutionProvider -
getCreditAccountTransactionExecutionProvider
@Deprecated protected CreditAccountTransactionExecutionProvider getCreditAccountTransactionExecutionProvider()Deprecated.since 1.8.1, no longer used as store credit balance validation is moved toCartPaymentMethodValidationActivity -
setCreditAccountTransactionExecutionProvider
@Deprecated @Autowired public void setCreditAccountTransactionExecutionProvider(CreditAccountTransactionExecutionProvider creditAccountTransactionExecutionProvider) Deprecated.since 1.8.1, no longer used as store credit balance validation is moved toCartPaymentMethodValidationActivity
-
CartPaymentMethodValidationActivity