Class DefaultCheckoutWorkflow

    • Method Detail

      • execute

        public com.broadleafcommerce.cart.client.domain.Cart execute​(@NonNull
                                                                     @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                                     @NonNull
                                                                     @NonNull String requestId,
                                                                     @NonNull
                                                                     @NonNull Map<String,​String> paymentLockTokens,
                                                                     @NonNull
                                                                     @NonNull Map<String,​String> securityCodes,
                                                                     @Nullable
                                                                     com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: CheckoutWorkflow
        Method used to coordinate the execution of CheckoutWorkflowActivities. If there is an exception/error during the execution of those activities, then CheckoutWorkflow.rollback(Cart, String, ContextInfo) should be called to un-do the work that had been done up to the point of the exception/error.
        Specified by:
        execute in interface CheckoutWorkflow
        Parameters:
        cart - The Cart that we're attempting to checkout with.
        requestId - The id used to identify changes tied to the specific execution request
        paymentLockTokens - Tokens that grant this service access to act upon the payment. The presence of these tokens indicates that this execution flow owns the lock.
        securityCodes - The map of card security codes keyed by payment id for processing saved payments
        contextInfo - Context information around sandbox and multitenant state.
        Returns:
        The final state of the cart following the execution of the workflow.
      • unlockPayments

        protected void unlockPayments​(@NonNull
                                      @NonNull Map<String,​String> paymentLockTokens,
                                      @Nullable
                                      com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • 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: CheckoutWorkflow
        Method used to coordinate the rollback of work that has been done by the CheckoutWorkflowActivities up to that point.
        Specified by:
        rollback in interface CheckoutWorkflow
        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 execution of the workflow rollback.
      • logErrorInitiatingWorkflowRollback

        protected void logErrorInitiatingWorkflowRollback​(@NonNull
                                                          @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                          @NonNull
                                                          @NonNull String requestId,
                                                          Exception e)
        Log a message to record the initiation of the workflow rollback
        Parameters:
        cart - The cart that is being acted upon in this workflow
        requestId - The id used to identify changes tied to the specific execution request
        e - The exception thrown by the CheckoutWorkflowActivity
      • executeActivity

        protected com.broadleafcommerce.cart.client.domain.Cart executeActivity​(@NonNull
                                                                                @NonNull CheckoutWorkflowActivity activity,
                                                                                @NonNull
                                                                                @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                                                @NonNull
                                                                                @NonNull String requestId,
                                                                                @NonNull
                                                                                @NonNull Map<String,​String> paymentLockTokens,
                                                                                @NonNull
                                                                                @NonNull Map<String,​String> securityCodes,
                                                                                @Nullable
                                                                                com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • logErrorInitiatingWorkflowRollback

        protected void logErrorInitiatingWorkflowRollback​(@NonNull
                                                          @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                          @NonNull
                                                          @NonNull String requestId,
                                                          @NonNull
                                                          @NonNull CheckoutWorkflowActivityException e)
      • sendCheckoutRollbackEvent

        protected void sendCheckoutRollbackEvent​(@NonNull
                                                 @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                 @NonNull
                                                 @NonNull String requestId,
                                                 @Nullable
                                                 com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Send a message to notify external services (and internal listeners) of the checkout workflow rollback, so that they can react accordingly.
        Parameters:
        cart - The cart that is being evaluated for checkout.
        requestId - The checkout request id
        contextInfo - Context information around sandbox and multitenant state.
      • recordWorkflowError

        protected com.broadleafcommerce.cart.client.domain.Cart recordWorkflowError​(@NonNull
                                                                                    @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                                                    @NonNull
                                                                                    @NonNull String requestId,
                                                                                    @NonNull
                                                                                    @NonNull CheckoutWorkflowActivityException e,
                                                                                    @Nullable
                                                                                    com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Method responsible for recording the error that was encountered during the activity's execution.
        Parameters:
        cart - The cart that is being acted upon in this workflow
        requestId - The id used to identify changes tied to the specific execution request
        e - The exception thrown by the CheckoutWorkflowActivity
        contextInfo - Context information around sandbox and multitenant state.
        Returns:
        The cart including the recorded activity execution state
      • recordRollbackError

        protected com.broadleafcommerce.cart.client.domain.Cart recordRollbackError​(@NonNull
                                                                                    @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                                                    @NonNull
                                                                                    @NonNull String requestId,
                                                                                    @NonNull
                                                                                    @NonNull Exception e,
                                                                                    @Nullable
                                                                                    com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Method responsible for recording the error that was encountered during the activity's rollback.
        Parameters:
        cart - The cart that encountered an error during the execution of this activity
        requestId - The id used to identify changes tied to the specific execution request
        e -
        contextInfo - Context information around sandbox and multitenant state.
        Returns:
        The cart including the recorded activity rollback state
      • getCartProvider

        protected CartProvider getCartProvider()
      • getTypeFactory

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

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

        @Autowired
        @Qualifier("checkoutWorkflowRollbackMessageRetryTemplate")
        public void setMessageRetryTemplate​(org.springframework.retry.support.RetryTemplate messageRetryTemplate)
      • getMessageRetryTemplate

        protected org.springframework.retry.support.RetryTemplate getMessageRetryTemplate()