Class DefaultExternalPaymentTransactionCallbackService
java.lang.Object
com.broadleafcommerce.cartoperation.service.payment.DefaultExternalPaymentTransactionCallbackService
- All Implemented Interfaces:
ExternalPaymentTransactionCallbackService
public class DefaultExternalPaymentTransactionCallbackService
extends Object
implements ExternalPaymentTransactionCallbackService
Service used to interpret the results of an external payment transaction callback, possibly
trigger the finalization of the cart, & communicate the result of the interaction via the
ExternalPaymentTransactionCallbackDTO
.- Author:
- Dima Myroniuk (dmyroniuk)
-
Constructor Summary
ConstructorDescriptionDefaultExternalPaymentTransactionCallbackService
(CartProvider cartProvider, PaymentTransactionExecutionProvider paymentTransactionProvider, PaymentProvider<PaymentSummary> paymentProvider, CartOperationCheckoutProperties checkoutProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected ExternalPaymentTransactionCallbackDTO
addRedirectAttributes
(@NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) buildHandleExternalTransactionRequest
(@NonNull ExternalPaymentTransactionCallbackDTO callbackDTO) protected PaymentCallbackValidationRequest
buildPaymentCallbackValidationRequest
(@NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Optional<PaymentSummary>
findPaymentAwaitingAsyncResults
(@NonNull List<PaymentSummary> cartPayments, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Optional<PaymentSummary>
findPaymentRequiringExternalInteraction
(@NonNull List<PaymentSummary> cartPayments, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected ExternalPaymentTransactionCallbackDTO
gatherAndHandleTransactionResults
(@NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected TransactionExecutionResponse
gatherTransactionResult
(@NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected String
getApplicationIdFromContext
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected CartProvider
protected CartOperationCheckoutProperties
protected String
getCheckoutTransactionType
(@NonNull PaymentSummary paymentSummary, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Based on the providedPaymentSummary
, determine whichTransactionType
should be used to execute the payment stage of the checkout.protected PaymentProvider<PaymentSummary>
protected PaymentTransactionExecutionProvider
getRequestParamsToExclude
(@NonNull ExternalPaymentTransactionCallbackDTO callbackDTO) protected String
getTenantIdFromContext
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected com.broadleafcommerce.common.extension.TypeFactory
protected com.broadleafcommerce.data.tracking.core.context.ContextInfo
getUpdateContextInfo
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) handleCallback
(@NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Interprets the results of an external payment transaction callback, possibly triggers the finalization of the cart, & communicates the result of the interaction via theExternalPaymentTransactionCallbackDTO
.protected ExternalPaymentTransactionCallbackDTO
handleTransactionResult
(@NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, @NonNull TransactionExecutionResponse transactionExecutionResponse, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected boolean
isAnonymousCart
(com.broadleafcommerce.cart.client.domain.Cart cart) protected boolean
isPaymentCancelled
(@NonNull TransactionExecutionResponse transactionExecutionResponse) protected boolean
isPaymentExpired
(@NonNull TransactionExecutionResponse transactionExecutionResponse) protected boolean
paymentRequires3dsInteraction
(@NonNull PaymentSummary paymentSummary, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected boolean
paymentRequiresExternalInteraction
(@NonNull PaymentSummary paymentSummary, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected boolean
successfulPaymentAmountsMatchCartTotal
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull List<PaymentSummary> cartPayments, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if all the payments for the givenCart
add up to cart's total.protected void
triggerCartFinalization
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) validatePaymentCallback
(@NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates the results of an external payment transaction callback.
-
Constructor Details
-
DefaultExternalPaymentTransactionCallbackService
public DefaultExternalPaymentTransactionCallbackService(CartProvider cartProvider, PaymentTransactionExecutionProvider paymentTransactionProvider, PaymentProvider<PaymentSummary> paymentProvider, CartOperationCheckoutProperties checkoutProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
validatePaymentCallback
public ExternalPaymentTransactionCallbackDTO validatePaymentCallback(@NonNull @NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:ExternalPaymentTransactionCallbackService
Validates the results of an external payment transaction callback. If invalid, should return an emptyExternalPaymentTransactionCallbackDTO
so that no sensitive information can be returned to a potentially malicious request.- Specified by:
validatePaymentCallback
in interfaceExternalPaymentTransactionCallbackService
- Parameters:
callbackDTO
- The DTO used to communicate the cart & transaction data provided by the callback requestcontextInfo
- context information related to multitenancy- Returns:
- the validated
ExternalPaymentTransactionCallbackDTO
-
handleCallback
public ExternalPaymentTransactionCallbackDTO handleCallback(@NonNull @NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:ExternalPaymentTransactionCallbackService
Interprets the results of an external payment transaction callback, possibly triggers the finalization of the cart, & communicates the result of the interaction via theExternalPaymentTransactionCallbackDTO
.- Specified by:
handleCallback
in interfaceExternalPaymentTransactionCallbackService
- Parameters:
callbackDTO
- The DTO used to communicate the cart & transaction data provided by the callback requestcontextInfo
- context information related to multitenancy- Returns:
- An updated
ExternalPaymentTransactionCallbackDTO
describing the result of the external payment interaction
-
buildPaymentCallbackValidationRequest
protected PaymentCallbackValidationRequest buildPaymentCallbackValidationRequest(@NonNull @NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
gatherAndHandleTransactionResults
protected ExternalPaymentTransactionCallbackDTO gatherAndHandleTransactionResults(@NonNull @NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
addRedirectAttributes
protected ExternalPaymentTransactionCallbackDTO addRedirectAttributes(@NonNull @NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
isAnonymousCart
protected boolean isAnonymousCart(@Nullable com.broadleafcommerce.cart.client.domain.Cart cart) -
handleTransactionResult
protected ExternalPaymentTransactionCallbackDTO handleTransactionResult(@NonNull @NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, @NonNull @NonNull TransactionExecutionResponse transactionExecutionResponse, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
successfulPaymentAmountsMatchCartTotal
protected boolean successfulPaymentAmountsMatchCartTotal(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull List<PaymentSummary> cartPayments, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if all the payments for the givenCart
add up to cart's total.If all the cart's payments have results but the amounts don't add up to cart's total, that means one or more payments failed, as failed transactions are excluded from the amounts in
PaymentSummary
.- Parameters:
cart
- theCart
to check againstcontextInfo
- context information around sandbox and multitenant state- Returns:
- true if all the payments for the given
Cart
match the cart's total, otherwise false - Throws:
UnsupportedOperationException
- if the checkout transaction type is not supported
-
getCheckoutTransactionType
protected String getCheckoutTransactionType(@NonNull @NonNull PaymentSummary paymentSummary, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Based on the providedPaymentSummary
, determine whichTransactionType
should be used to execute the payment stage of the checkout.- Parameters:
paymentSummary
- One of the cart's payment summaries- Returns:
- The desired transaction type for the gateway
-
gatherTransactionResult
protected TransactionExecutionResponse gatherTransactionResult(@NonNull @NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
buildHandleExternalTransactionRequest
protected Map<String,Object> buildHandleExternalTransactionRequest(@NonNull @NonNull ExternalPaymentTransactionCallbackDTO callbackDTO) -
getUpdateContextInfo
@Nullable protected com.broadleafcommerce.data.tracking.core.context.ContextInfo getUpdateContextInfo(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
triggerCartFinalization
protected void triggerCartFinalization(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
findPaymentRequiringExternalInteraction
protected Optional<PaymentSummary> findPaymentRequiringExternalInteraction(@NonNull @NonNull List<PaymentSummary> cartPayments, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
paymentRequires3dsInteraction
protected boolean paymentRequires3dsInteraction(@NonNull @NonNull PaymentSummary paymentSummary, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
paymentRequiresExternalInteraction
protected boolean paymentRequiresExternalInteraction(@NonNull @NonNull PaymentSummary paymentSummary, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
findPaymentAwaitingAsyncResults
protected Optional<PaymentSummary> findPaymentAwaitingAsyncResults(@NonNull @NonNull List<PaymentSummary> cartPayments, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
isPaymentExpired
protected boolean isPaymentExpired(@NonNull @NonNull TransactionExecutionResponse transactionExecutionResponse) -
isPaymentCancelled
protected boolean isPaymentCancelled(@NonNull @NonNull TransactionExecutionResponse transactionExecutionResponse) -
getRequestParamsToExclude
protected Set<String> getRequestParamsToExclude(@NonNull @NonNull ExternalPaymentTransactionCallbackDTO callbackDTO) -
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) -
getCartProvider
-
getPaymentTransactionProvider
-
getPaymentProvider
-
getCheckoutProperties
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-