Class CartPaymentMethodValidationActivity

    • Method Detail

      • execute

        public com.broadleafcommerce.cart.client.domain.Cart execute​(@NonNull
                                                                     @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                                     @NonNull
                                                                     @NonNull String requestId,
                                                                     @Nullable
                                                                     com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: CheckoutWorkflowActivity
        Method responsible for executing some work against the cart that is required for checkout. This may include, but is not limited to, cart validation checks, inventory reservations, or payment authorizations.
        Specified by:
        execute in interface CheckoutWorkflowActivity
        Parameters:
        cart - The Cart that we're attempting to checkout with.
        requestId - The id used to identify changes tied to the specific execution request
        contextInfo - Context information around sandbox and multitenant state.
        Returns:
        The final state of the cart following the execution of the activity.
      • rollback

        public com.broadleafcommerce.cart.client.domain.Cart rollback​(@NonNull
                                                                      @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                                      @NonNull
                                                                      @NonNull String requestId,
                                                                      @Nullable
                                                                      com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: CheckoutWorkflowActivity
        Method responsible for rolling back any work that was done during the execution of the #execute(Cart, String) method.
        Specified by:
        rollback in interface CheckoutWorkflowActivity
        Parameters:
        cart - The Cart that we were attempting to checkout with, but ran into an exception/error.
        requestId - The id used to identify changes tied to the specific execution request
        contextInfo - Context information around sandbox and multitenant state.
        Returns:
        The final state of the cart following the rollback of the activity.
      • validateCartHasActivePayment

        protected void validateCartHasActivePayment​(@NonNull
                                                    @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                    @NonNull
                                                    @NonNull List<PaymentSummary> paymentSummaries)
        Validate that the cart has at least one active payment.
        Parameters:
        cart - the Cart that we're attempting to checkout with
        paymentSummaries - the payment summaries for the specified cart
      • validatePaymentMethodAvailability

        protected void validatePaymentMethodAvailability​(@NonNull
                                                         @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                         @NonNull
                                                         @NonNull List<PaymentSummary> paymentSummaries,
                                                         @Nullable
                                                         com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Validate that the payments on the cart are available in the current context.
        Parameters:
        cart - the Cart that we're attempting to checkout with
        paymentSummaries - the payment summaries for the specified cart
      • validatePaymentAmount

        protected void validatePaymentAmount​(@NonNull
                                             @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                             @NonNull
                                             @NonNull List<PaymentSummary> paymentSummaries)
        Validate that each of the PaymentSummaries are responsible for a zero or greater amount. In some cases, a zero amount may be useful to signify a tokenized payment to be used in future billing (e.g. a free trial offer that allows an order to be placed with zero up front and billed the full amount after the trial expires or a "post-paid" plan product that is charged nothing up front and the actual bill amount is determined by usage at a later date).
        Parameters:
        cart - the Cart that we're attempting to checkout with
        paymentSummaries - the payment summaries for the specified cart
      • validatePaymentAmountSum

        protected void validatePaymentAmountSum​(@NonNull
                                                @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                @NonNull
                                                @NonNull List<PaymentSummary> paymentSummaries,
                                                @Nullable
                                                com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Validate that the sum of the PaymentSummary amounts is equal to the cart total (CartPricing.getTotal()).
        Parameters:
        cart - the Cart that we're attempting to checkout with
        paymentSummaries - the payment summaries for the specified cart
        contextInfo - context information around sandbox and multitenant state
      • validatePaymentTransactionAmountSums

        protected void validatePaymentTransactionAmountSums​(@NonNull
                                                            @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                            @NonNull
                                                            @NonNull List<PaymentSummary> paymentSummaries,
                                                            @Nullable
                                                            com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Validates that the sum of authorized/captured amount of the successful transactions equal to the payment amount.
        Parameters:
        cart - the Cart that we're attempting to checkout with
        paymentSummaries - the payment summaries for the specified cart
        contextInfo - context information around sandbox and multitenant state
      • hasValidAmountAuthorizedOrCaptured

        protected boolean hasValidAmountAuthorizedOrCaptured​(@NonNull
                                                             @NonNull javax.money.MonetaryAmount amountAuthorizedOrCapturedOrPending,
                                                             @NonNull
                                                             @NonNull PaymentSummary paymentSummary,
                                                             @Nullable
                                                             com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Validates that the amount authorized or captured fully covers the payment total amount.
        Parameters:
        amountAuthorizedOrCapturedOrPending - the amount authorized or captured or awaiting capture result
        paymentSummary - the payment summary
        contextInfo - context information around sandbox and multitenant state
        Returns:
        true if the amount authorized or captured fully covers the payment total amount, false otherwise
      • isExternalTransactionExpected

        protected boolean isExternalTransactionExpected​(@NonNull
                                                        @NonNull PaymentSummary paymentSummary,
                                                        @Nullable
                                                        com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Based on the provided PaymentGatewayType, determine if the expected transaction is external.
        Parameters:
        paymentSummary - the payment summary
        contextInfo - context information around sandbox and multitenant state
      • getCheckoutTransactionType

        protected String getCheckoutTransactionType​(@NonNull
                                                    @NonNull String gatewayType,
                                                    @Nullable
                                                    com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Based on the provided PaymentGatewayType, determine which TransactionType should 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
        contextInfo - Context information around sandbox and multitenant state
        Returns:
        The desired transaction type for the gateway
        See Also:
        CartOperationCheckoutProperties.getCheckoutTransactionTypeByGateway(String, String, String)
      • getZeroAmount

        protected javax.money.MonetaryAmount getZeroAmount​(@NonNull
                                                           @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                           @Nullable
                                                           com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • getCurrencyUnit

        @NonNull
        protected javax.money.CurrencyUnit getCurrencyUnit​(com.broadleafcommerce.cart.client.domain.Cart cart,
                                                           @Nullable
                                                           com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • getZeroAmount

        @NonNull
        protected javax.money.MonetaryAmount getZeroAmount​(@NonNull
                                                           @NonNull javax.money.CurrencyUnit currencyUnit)
      • getMessage

        protected String getMessage​(@NonNull
                                    @NonNull String errorMessage,
                                    @Nullable
                                    Object... args)
      • 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)
      • getMessageSource

        protected org.springframework.context.MessageSource getMessageSource()
      • setCheckoutPaymentMethodService

        @Autowired
        public void setCheckoutPaymentMethodService​(CheckoutPaymentMethodService checkoutPaymentMethodService)