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 Details

  • 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 empty ExternalPaymentTransactionCallbackDTO so that no sensitive information can be returned to a potentially malicious request.
      Specified by:
      validatePaymentCallback in interface ExternalPaymentTransactionCallbackService
      Parameters:
      callbackDTO - The DTO used to communicate the cart & transaction data provided by the callback request
      contextInfo - 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 the ExternalPaymentTransactionCallbackDTO.
      Specified by:
      handleCallback in interface ExternalPaymentTransactionCallbackService
      Parameters:
      callbackDTO - The DTO used to communicate the cart & transaction data provided by the callback request
      contextInfo - 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 given Cart 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 - the Cart to check against
      contextInfo - 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 provided PaymentSummary, determine which TransactionType 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

      protected CartProvider getCartProvider()
    • getPaymentTransactionProvider

      protected PaymentTransactionExecutionProvider getPaymentTransactionProvider()
    • getPaymentProvider

      protected PaymentProvider<PaymentSummary> getPaymentProvider()
    • getCheckoutProperties

      protected CartOperationCheckoutProperties getCheckoutProperties()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()