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
ConstructorsConstructorDescriptionDefaultExternalPaymentTransactionCallbackService(CartProvider cartProvider, PaymentTransactionExecutionProvider paymentTransactionProvider, PaymentProvider<PaymentSummary> paymentProvider, CartOperationCheckoutProperties checkoutProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected ExternalPaymentTransactionCallbackDTOaddRedirectAttributes(@NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) buildHandleExternalTransactionRequest(@NonNull ExternalPaymentTransactionCallbackDTO callbackDTO) protected PaymentCallbackValidationRequestbuildPaymentCallbackValidationRequest(@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 ExternalPaymentTransactionCallbackDTOgatherAndHandleTransactionResults(@NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected TransactionExecutionResponsegatherTransactionResult(@NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected StringgetApplicationIdFromContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected CartProviderprotected CartOperationCheckoutPropertiesprotected StringgetCheckoutTransactionType(@NonNull PaymentSummary paymentSummary, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Based on the providedPaymentSummary, determine whichTransactionTypeshould be used to execute the payment stage of the checkout.protected PaymentProvider<PaymentSummary>protected PaymentTransactionExecutionProvidergetRequestParamsToExclude(@NonNull ExternalPaymentTransactionCallbackDTO callbackDTO) protected StringgetTenantIdFromContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected com.broadleafcommerce.common.extension.TypeFactoryprotected com.broadleafcommerce.data.tracking.core.context.ContextInfogetUpdateContextInfo(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 ExternalPaymentTransactionCallbackDTOhandleTransactionResult(@NonNull ExternalPaymentTransactionCallbackDTO callbackDTO, @NonNull TransactionExecutionResponse transactionExecutionResponse, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected booleanisAnonymousCart(com.broadleafcommerce.cart.client.domain.Cart cart) protected booleanisPaymentCancelled(@NonNull TransactionExecutionResponse transactionExecutionResponse) protected booleanisPaymentExpired(@NonNull TransactionExecutionResponse transactionExecutionResponse) protected booleanpaymentRequires3dsInteraction(@NonNull PaymentSummary paymentSummary, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected booleanpaymentRequiresExternalInteraction(@NonNull PaymentSummary paymentSummary, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected booleansuccessfulPaymentAmountsMatchCartTotal(@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 givenCartadd up to cart's total.protected voidtriggerCartFinalization(@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:ExternalPaymentTransactionCallbackServiceValidates the results of an external payment transaction callback. If invalid, should return an emptyExternalPaymentTransactionCallbackDTOso that no sensitive information can be returned to a potentially malicious request.- Specified by:
validatePaymentCallbackin 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:ExternalPaymentTransactionCallbackServiceInterprets 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:
handleCallbackin 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
ExternalPaymentTransactionCallbackDTOdescribing 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 givenCartadd 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- theCartto check againstcontextInfo- context information around sandbox and multitenant state- Returns:
- true if all the payments for the given
Cartmatch 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 whichTransactionTypeshould 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()
-