Class DefaultCheckoutService

java.lang.Object
com.broadleafcommerce.cartoperation.service.checkout.DefaultCheckoutService
All Implemented Interfaces:
CheckoutService

public class DefaultCheckoutService extends Object implements CheckoutService
Default implementation of the CheckoutService that is responsible for processing checkout requests
Author:
Chad Harchar (charchar), Chris Kittrell (ckittrell)
  • Constructor Details

  • Method Details

    • processCheckout

      public CheckoutResponse processCheckout(@NonNull @NonNull CheckoutProcessDto processDto, @NonNull @NonNull Map<String,String> securityCodes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CheckoutService
      Process checkout against the provided CheckoutProcessDto.
      Specified by:
      processCheckout in interface CheckoutService
      Parameters:
      processDto - The CheckoutProcessDto for processing checkout
      securityCodes - Secure codes that are passed to the gateway for verification during authorization or capture transactions
      contextInfo - Context information around sandbox and multitenant state
      Returns:
      The CheckoutResponse containing the result of the checkout process
    • validateCheckoutRequest

      @Deprecated(since="1.8.0", forRemoval=true) protected void validateCheckoutRequest(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Validates the cart for checkout.
      Parameters:
      cart - The cart to validate
      requestId - The checkout request id
    • finalizeCheckout

      public CheckoutProcessDto finalizeCheckout(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CheckoutService
      Finalizes checkout for the given Cart.

      This is typically used for processes that need to finalize checkout outside the checkout workflow, such as FinalizeCartAwaitingPaymentResultJobListener.

      Specified by:
      finalizeCheckout in interface CheckoutService
      Parameters:
      processDto - the CheckoutProcessDto containing the cart to finalize
      contextInfo - Context information around sandbox and multitenant state.
      Returns:
      the finalized CheckoutProcessDto
    • buildSubmittedCheckoutResponse

      public CheckoutResponse buildSubmittedCheckoutResponse(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CheckoutService
      Builds a successful checkout response for the submitted cart.
      Specified by:
      buildSubmittedCheckoutResponse in interface CheckoutService
      Parameters:
      cart - The cart that was submitted
      contextInfo - Context information around sandbox and multitenant state.
      Returns:
      A successful checkout response for the cart
    • sendCartPendingPaymentFailedEvent

      public void sendCartPendingPaymentFailedEvent(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CheckoutService
      Send a message to notify external services (and internal listeners) of the cart pending payment failed, so that they can react accordingly.
      Specified by:
      sendCartPendingPaymentFailedEvent in interface CheckoutService
      Parameters:
      cart - The cart in which one or more of its pending payments failed.
      contextInfo - Context information around sandbox and multitenant state.
    • resendCheckoutCompletionEvent

      public SendCheckoutEventResponse resendCheckoutCompletionEvent(@NonNull @NonNull String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CheckoutService
      Resend CheckoutCompletionEvent for the given cart id.

      This is useful to manually recover from scenarios where the cart was finalized for checkout but the CheckoutCompletionEvent failed to send.

      Specified by:
      resendCheckoutCompletionEvent in interface CheckoutService
      Parameters:
      cartId - the cart id to resend the CheckoutCompletionEvent for
      contextInfo - context information around sandbox and multitenant state
      Returns:
      a SendCheckoutEventResponse containing the details for this request
    • resendCheckoutRollbackEvent

      public SendCheckoutEventResponse resendCheckoutRollbackEvent(@NonNull @NonNull String cartId, @NonNull @NonNull String requestId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CheckoutService
      Resend CheckoutRollbackEvent for the given cart id.

      This is useful to manually recover from scenarios where the cart was rolled back but the CheckoutRollbackEvent failed to send.

      Specified by:
      resendCheckoutRollbackEvent in interface CheckoutService
      Parameters:
      cartId - the cart id to resend the CheckoutRollbackEvent for
      requestId - the checkout request id to resend the CheckoutRollbackEvent for
      contextInfo - context information around sandbox and multitenant state
      Returns:
      a SendCheckoutEventResponse containing the details for this request
    • resendCartPendingPaymentFailedEvent

      public SendCheckoutEventResponse resendCartPendingPaymentFailedEvent(@NonNull @NonNull String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CheckoutService
      Resend CartPendingPaymentFailedEvent for the given cart id.

      This is useful to manually recover from scenarios where the cart status was updated to DefaultCartStatuses.PENDING_PAYMENT_FAILED but the CartPendingPaymentFailedEvent failed to send.

      Specified by:
      resendCartPendingPaymentFailedEvent in interface CheckoutService
      Parameters:
      cartId - the cart id to resend the CartPendingPaymentFailedEvent for
      contextInfo - context information around sandbox and multitenant state
      Returns:
      a SendCheckoutEventResponse containing the details for this request
    • resendCartAwaitingPaymentResultsEvent

      public SendCheckoutEventResponse resendCartAwaitingPaymentResultsEvent(@NonNull @NonNull String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CheckoutService
      Resend CartAwaitingPaymentResultsEvent for the given cart id.

      This is useful to manually recover from scenarios where the cart was awaiting payment results but the CartAwaitingPaymentResultsEvent failed to send.

      Specified by:
      resendCartAwaitingPaymentResultsEvent in interface CheckoutService
      Parameters:
      cartId - the cart id to resend the CartAwaitingPaymentResultsEvent for
      contextInfo - context information around sandbox and multitenant state
      Returns:
      a SendCheckoutEventResponse containing the details for this request
    • resendExternalPaymentTransactionCartFinalizationEvent

      public SendCheckoutEventResponse resendExternalPaymentTransactionCartFinalizationEvent(@NonNull @NonNull String cartId, @NonNull @NonNull String checkoutRequestId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CheckoutService
      Specified by:
      resendExternalPaymentTransactionCartFinalizationEvent in interface CheckoutService
      Parameters:
      cartId - the cart id to resend the ExternalPaymentTransactionCartFinalizationEvent for
      checkoutRequestId - the checkout request id to resend the ExternalPaymentTransactionCartFinalizationEvent for
      contextInfo - context information around sandbox and multitenant state
      Returns:
      a SendCheckoutEventResponse containing the details for this request
    • validateResendCheckoutCompletionEvent

      protected org.apache.commons.lang3.tuple.Pair<Boolean,String> validateResendCheckoutCompletionEvent(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable String requestId)
      Validates if the checkout completion event can be resent for the given Cart
      Parameters:
      cart - the Cart used to validate if the event can be resent
      requestId - the checkout request id
      Returns:
      a Pair with key of validation result and value of validation message, if any
    • validateResendCheckoutRollbackEvent

      protected org.apache.commons.lang3.tuple.Pair<Boolean,String> validateResendCheckoutRollbackEvent(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId)
      Validates if the checkout rollback event can be resent for the given Cart
      Parameters:
      cart - the Cart used to validate if the event can be resent
      requestId - the checkout request id
      Returns:
      a Pair with key of validation result and value of validation message, if any
    • validateResendPendingPaymentFailedEvent

      protected org.apache.commons.lang3.tuple.Pair<Boolean,String> validateResendPendingPaymentFailedEvent(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable String requestId)
      Validates if the pending payment failed event can be resent for the given Cart
      Parameters:
      cart - the Cart used to validate if the event can be resent
      requestId - the checkout request id
      Returns:
      a Pair with key of validation result and value of validation message, if any
    • validateResendCartAwaitingPaymentResultsEvent

      protected org.apache.commons.lang3.tuple.Pair<Boolean,String> validateResendCartAwaitingPaymentResultsEvent(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable String requestId)
      Validates if the awaiting payment result event can be resent for the given Cart
      Parameters:
      cart - the Cart used to validate if the event can be resent
      requestId - the checkout request id
      Returns:
      a Pair with key of validation result and value of validation message, if any
    • sendEvent

      protected SendCheckoutEventResponse sendEvent(@NonNull @NonNull BiFunction<com.broadleafcommerce.cart.client.domain.Cart,String,org.apache.commons.lang3.tuple.Pair<Boolean,String>> validateEventCanResend, @NonNull @NonNull org.apache.camel.util.function.TriConsumer<com.broadleafcommerce.cart.client.domain.Cart,String,com.broadleafcommerce.data.tracking.core.context.ContextInfo> sendConsumer, String cartId, @Nullable String requestId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Sends the event with the given TriConsumer, cart id, and ContextInfo.
      Parameters:
      validateEventCanResend - the BiFunction used to validate if the event can be resent for the cart
      sendConsumer - the TriConsumer used to send the event
      cartId - the cart id
      contextInfo - context information around sandbox and multitenant state
      Returns:
      a SendCheckoutEventResponse containing the details for this request
    • sendPendingPaymentFailedEventToProvider

      protected void sendPendingPaymentFailedEventToProvider(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Send the CartPendingPaymentFailedEvent to CartProvider for durable sending.
      Parameters:
      cart - The cart that is being evaluated for checkout.
      contextInfo - Context information around sandbox and multitenant state.
    • validateResendExternalPaymentTransactionCartFinalizationEvent

      protected org.apache.commons.lang3.tuple.Pair<Boolean,String> validateResendExternalPaymentTransactionCartFinalizationEvent(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId)
      Validates if the webhook checkout failed event can be resent for the given Cart
      Parameters:
      cart - the Cart used to validate if the event can be resent
      requestId - the checkout request id
      Returns:
      a Pair with key of validation result and value of validation message, if any
    • sendExternalPaymentTransactionCartFinalizationEventToProvider

      protected void sendExternalPaymentTransactionCartFinalizationEventToProvider(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Parameters:
      cart - The related Cart
      contextInfo - Context information around sandbox and multitenant state.
    • getLatestCheckoutRequestId

      protected String getLatestCheckoutRequestId(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
      Gets the latest checkout request id for the given Cart.
      Parameters:
      cart - the Cart to get the latest checkout request id from
      Returns:
      the latest checkout request id for the given Cart
    • buildSuccessSendCheckoutEventResponse

      protected SendCheckoutEventResponse buildSuccessSendCheckoutEventResponse(@NonNull @NonNull String cartId)
      Builds a successful SendCheckoutEventResponse.
      Parameters:
      cartId - the cart id that was requested to send the event
      Returns:
      a successful SendCheckoutEventResponse
    • buildFailedSendCheckoutEventResponse

      protected SendCheckoutEventResponse buildFailedSendCheckoutEventResponse(@NonNull @NonNull String cartId, @Nullable String failureMessage)
      Builds a failed SendCheckoutEventResponse.
      Parameters:
      cartId - the cart id that was requested to send the event
      failureMessage - the message about the failure
      Returns:
      a failed SendCheckoutEventResponse
    • validateCheckoutRequest

      protected void validateCheckoutRequest(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Validates the cart for checkout
      Parameters:
      processDto - The CheckoutProcessDto to validate
      contextInfo - Context information around sandbox and multitenant state.
    • validateRequestId

      protected void validateRequestId(@NonNull @NonNull CheckoutProcessDto processDto)
      Validates that the current requestId is not already associated to the cart
      Parameters:
      processDto - The CheckoutProcessDto containing the request id to validate
      Throws:
      CheckoutWorkflowException - Thrown if the current requestId is already present in the cart's past checkout submissions
    • prepareCartForCheckout

      protected CheckoutProcessDto prepareCartForCheckout(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Prepares the cart for checkout.

      Updates the Cart.getStatus() and Cart.getCheckoutSubmissions() by default.

      Parameters:
      processDto - The CheckoutProcessDto containing the cart to prepare for checkout
      contextInfo - Context information around sandbox and multitenant state
      Returns:
      the CheckoutProcessDto containing the latest cart
    • lockPayments

      @Deprecated(since="1.7.7", forRemoval=true) protected Map<String,String> lockPayments(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 1.7.7, in favor of lockAndRetrievePayments(CheckoutProcessDto, ContextInfo)
      Sends request to PaymentTransactionServices to lock the cart's related payments. This is done to ensure that all of the work done within the CheckoutWorkflow and checkout process in general is consistently interacting with payments that will not change. With these locks in place, only this executing process will have access to modify the payments, until the lock TTL expires. Note: make sure that the checkout process can sufficiently be contained within the payment lock TTL. This can be configured in PaymentTransactionServices.
      Parameters:
      cart - the cart whose payments are to be locked
      contextInfo - The context of the user's request
      Returns:
      A map of payment id to lock token.
    • unlockPayments

      protected void unlockPayments(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Sends a request to PaymentTransactionServices to unlock the cart's payments, based on the lock tokens that were previously obtained via PaymentProvider.lockAndRetrieveCartPayments(Cart, ContextInfo).
      Parameters:
      processDto - The CheckoutProcessDto that contains a map of payment id to lock token that was previously obtained by calling PaymentProvider.lockAndRetrieveCartPayments(Cart, ContextInfo)
      contextInfo - The context of the user's request
    • updateCartStatus

      protected com.broadleafcommerce.cart.client.domain.Cart updateCartStatus(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String cartStatus, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • updateCartStatus

      protected com.broadleafcommerce.cart.client.domain.Cart updateCartStatus(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String cartStatus, boolean updateCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • removeStaleCartItems

      protected CheckoutProcessDto removeStaleCartItems(@NonNull @NonNull CheckoutProcessDto processDto, @NonNull @NonNull CheckoutException e, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Removes CartItems from the Cart that can no longer be found in the catalog & reprices the cart.
      Parameters:
      processDto - The CheckoutProcessDto that contains the cart with stale cart items
      e - The CheckoutException thrown due to the presence of stale cart items
      contextInfo - context information around sandbox and multitenant state
      Returns:
      The updated CheckoutProcessDto containing the repriced (but not updated) cart that no longer includes stale cart items
    • shouldResetCartStatus

      protected boolean shouldResetCartStatus(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String originalCartStatus, @NonNull @NonNull RuntimeException e)
      Determines whether or not the cart's status should be reset after encountering an unexpected exception during checkout.
      Parameters:
      cart - The cart related to the checkout request
      originalCartStatus - The status of the cart prior to attempting checkout
      e - The CheckoutWorkflowException that caused the checkout to fail
      Returns:
      whether or not the cart's status should be reset after encountering an unexpected exception during checkout.
    • finalizeCart

      @Deprecated(since="1.8.0", forRemoval=true) protected com.broadleafcommerce.cart.client.domain.Cart finalizeCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull Map<String,String> paymentLockTokens, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Following a successful checkout, this method is responsible for recording the finalized state of the cart.
      Parameters:
      cart - The cart that has completed checkout, but needs to be marked as finalized
      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.
      contextInfo - context information around sandbox and multitenant state
      Returns:
      The finalized cart
    • finalizeCart

      protected CheckoutProcessDto finalizeCart(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Following a successful checkout, this method is responsible for recording the finalized state of the cart.
      Parameters:
      processDto - the CheckoutProcessDto containing cart that has completed checkout, but needs to be marked as finalized
      contextInfo - context information around sandbox and multitenant state
      Returns:
      The CheckoutProcessDto containing the finalized cart
    • finalizePayments

      protected void finalizePayments(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • createOrderNumber

      protected String createOrderNumber(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
      Creates a new order number for a submitted cart.
      Returns:
      New order number for submitted cart.
    • sendCheckoutCompletionMessage

      protected void sendCheckoutCompletionMessage(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Builds a CheckoutProcessDto and delegates to sendCheckoutCompletionMessage(CheckoutProcessDto, ContextInfo).

      Useful to send CheckoutCompletionEvent outside of the checkout context.

      Parameters:
      cart - The cart that has completed checkout. This should be the primary content of the out-going message.
      requestId - The checkout request id
      contextInfo - Context information around sandbox and multitenant state.
    • sendCheckoutCompletionMessage

      protected void sendCheckoutCompletionMessage(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Send a message to notify external services (and internal listeners) of the completed checkout so that they can react accordingly.
      Parameters:
      processDto - The CheckoutProcessDto containing details about the successful checkout
      contextInfo - Context information around sandbox and multitenant state.
    • buildCheckoutCart

      protected com.broadleafcommerce.cart.client.domain.CheckoutCart buildCheckoutCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • addCartLinks

      protected void addCartLinks(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getFulfillmentGroupLink

      protected com.broadleafcommerce.cart.client.domain.CartLink getFulfillmentGroupLink(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getCartItemLink

      protected com.broadleafcommerce.cart.client.domain.CartLink getCartItemLink(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • populateAdjustments

      protected void populateAdjustments(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart)
      Populates the cart item, fulfillment item, and fulfillment group Adjustments and clear unneeded fields for the given CheckoutCart.
      Parameters:
      checkoutCart - the CheckoutCart to populate the adjustments for
    • clearAdjustmentFields

      protected void clearAdjustmentFields(@NonNull @NonNull List<com.broadleafcommerce.order.common.domain.Adjustment> adjustments)
      Clears unneeded Adjustment fields to reduce the payload size.
      Parameters:
      adjustments - a list of Adjustments to clear the unneeded fields for.
    • buildCheckoutResponseBasedOnCartStatus

      protected CheckoutResponse buildCheckoutResponseBasedOnCartStatus(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Builds a CheckoutResponse based on the cart status.
      Parameters:
      processDto - the CheckoutProcessDto containing the cart
      contextInfo - context information around sandbox and multitenant state
      Returns:
      a CheckoutResponse based on the cart status
    • sendCartAwaitingPaymentResultsEvent

      protected CheckoutProcessDto sendCartAwaitingPaymentResultsEvent(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • cartAwaitingPaymentResultsEvent

      protected void cartAwaitingPaymentResultsEvent(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Send a message to notify external services (and internal listeners) of the completed checkout so that they can react accordingly.
      Parameters:
      processDto - The CheckoutProcessDto containing details about the successful checkout
      contextInfo - Context information around sandbox and multitenant state.
    • buildAwaitingPaymentResultCheckoutResponse

      protected CheckoutResponse buildAwaitingPaymentResultCheckoutResponse(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Builds a CheckoutResponse signifying that the checkout submission is awaiting for payment result based on the given CheckoutProcessDto.

      Delegates to buildBaseCheckoutResponse(CheckoutProcessDto, boolean, ContextInfo) by default.

      Parameters:
      processDto - the CheckoutProcessDto to build the base CheckoutResponse from
      contextInfo - context information around sandbox and multitenant state
      Returns:
      a successful CheckoutResponse based on the given CheckoutProcessDto
    • buildSuccessfulCheckoutResponse

      protected CheckoutResponse buildSuccessfulCheckoutResponse(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Builds a successful CheckoutResponse based on the given CheckoutProcessDto.

      Delegates to buildBaseCheckoutResponse(CheckoutProcessDto, boolean, ContextInfo) by default.

      Parameters:
      processDto - the CheckoutProcessDto to build the base CheckoutResponse from
      contextInfo - context information around sandbox and multitenant state
      Returns:
      a successful CheckoutResponse based on the given CheckoutProcessDto
    • buildFailedCheckoutResponse

      @Deprecated protected CheckoutResponse buildFailedCheckoutResponse(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId, @NonNull @NonNull CheckoutWorkflowException e, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • buildFailedCheckoutResponse

      protected CheckoutResponse buildFailedCheckoutResponse(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId, @NonNull @NonNull CheckoutException e, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • buildFailedCheckoutResponse

      protected CheckoutResponse buildFailedCheckoutResponse(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId, @NonNull @NonNull PaymentLockException e, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • buildFailedCheckoutResponse

      protected CheckoutResponse buildFailedCheckoutResponse(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId, @NonNull @NonNull CartApprovalValidationException e, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • buildFailedCheckoutResponse

      protected CheckoutResponse buildFailedCheckoutResponse(@NonNull @NonNull CheckoutProcessDto processDto, @NonNull @NonNull RuntimeException exception, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Builds a failed CheckoutResponse based on the given CheckoutProcessDto and RuntimeException.
      Parameters:
      processDto - the CheckoutProcessDto to build the base CheckoutResponse from
      exception - the RuntimeException
      contextInfo - context information around sandbox and multitenant state
      Returns:
      a failed CheckoutResponse based on the given CheckoutProcessDto and RuntimeException
    • getMessage

      protected String getMessage(@NonNull @NonNull String errorMessage, @Nullable Object... args)
    • getPaymentNextActions

      protected List<PaymentNextAction> getPaymentNextActions(List<PaymentTransactionFailureDetail> paymentTransactionFailureDetails)
    • validateAccountCartSubmissionIfNecessary

      protected void validateAccountCartSubmissionIfNecessary(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      If the given Cart is an account cart, validates if the cart can be submitted by the given CustomerRef.

      By default, only customers with valid permissions can submit account carts.

      Parameters:
      processDto - the CheckoutProcessDto containing the cart and customer ref to validate
      contextInfo - context information around sandbox and multitenant state
    • validateQuoteCartSubmissionIfNecessary

      protected void validateQuoteCartSubmissionIfNecessary(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      If the given Cart is of type DefaultCartTypes.QUOTE, validates if the quote can be checked out.
      Parameters:
      processDto - the CheckoutProcessDto containing the cart and customer ref to validate
      contextInfo - context information around sandbox and multitenant state
    • buildChangeCartStatusRequestForValidation

      protected ChangeCartStatusRequest buildChangeCartStatusRequestForValidation(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String targetStatus, @NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef)
      Builds a ChangeCartStatusRequest used for validation purposes for checkout submission.
      Parameters:
      cart - the Cart being validated
      targetStatus - the target status that the Cart is changing to
      customerRef - the CustomerRef representing the currently authenticated user
      Returns:
      a ChangeCartStatusRequest based on the given params
    • finalizeAccountCartIfNecessary

      protected CheckoutProcessDto finalizeAccountCartIfNecessary(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finalizes the given account Cart if necessary.

      By default, this method just updates the approver email. Any custom logic should be added here.

      Parameters:
      processDto - the CheckoutProcessDto containing the account cart that was submitted
      contextInfo - context information around sandbox and multitenant state
      Returns:
      the latest CheckoutProcessDto
    • finalizeQuoteIfNecessary

      protected CheckoutProcessDto finalizeQuoteIfNecessary(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finalizes the given quote Cart if necessary.

      By default, this does nothing. This serves as a hook point for customization.

      Parameters:
      processDto - the CheckoutProcessDto containing the quote that was submitted
      contextInfo - context information around sandbox and multitenant state
      Returns:
      the latest CheckoutProcessDto
    • buildUpdateCartRequest

      protected UpdateCartRequest buildUpdateCartRequest(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String originalCartStatus)
      Builds an UpdateCartRequest based on the given properties.
      Parameters:
      cart - the Cart to update
      originalCartStatus - the original Cart.getStatus() prior checkout submission
      Returns:
      an UpdateCartRequest based on the given properties
    • buildCartActionAuditForSubmit

      @Deprecated protected com.broadleafcommerce.cart.client.domain.CartActionAudit buildCartActionAuditForSubmit(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String oldCartStatus)
      Deprecated.
      Builds a CartActionAudit for the submitted account Cart.

      By default, only approvers can submit account carts.

      Parameters:
      cart - the account Cart that was submitted
      oldCartStatus - the old Cart.getStatus()
    • buildCartActionAuditForCheckout

      protected com.broadleafcommerce.cart.client.domain.CartActionAudit buildCartActionAuditForCheckout(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String oldCartStatus, @NonNull @NonNull String userType)
      Builds a CartActionAudit for the submitted Cart.
      Parameters:
      cart - the Cart that was submitted
      oldCartStatus - the old Cart.getStatus()
      userType - the CartActionAudit.getUserType()
      See Also:
      • DefaultCartActionTypes
      • DefaultUserTypes
    • getCartStatusValidationHelper

      protected CartStatusValidationHelper getCartStatusValidationHelper()
    • getCheckoutWorkflow

      protected CheckoutWorkflow getCheckoutWorkflow()
    • getCartProvider

      protected CartProvider getCartProvider()
    • getCheckoutCompletionProducer

      protected com.broadleafcommerce.common.messaging.checkout.CheckoutCompletionProducer getCheckoutCompletionProducer()
    • getExternalCartProperties

      protected ExternalCartProperties getExternalCartProperties()
    • getPaymentProvider

      protected PaymentProvider<PaymentSummary> getPaymentProvider()
    • getMessageSource

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

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

      @Autowired public void setStaleCartItemsService(StaleCartItemsService staleCartItemsService)
    • getStaleCartItemsService

      protected StaleCartItemsService getStaleCartItemsService()
    • setMessageRetryTemplate

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

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

      @Autowired @Qualifier("cartPendingPaymentFailedMessageRetryTemplate") public void setPendingPaymentFailedRetryTemplate(org.springframework.retry.support.RetryTemplate pendingPaymentFailedRetryTemplate)
    • getPendingPaymentFailedRetryTemplate

      protected org.springframework.retry.support.RetryTemplate getPendingPaymentFailedRetryTemplate()
    • getAuthenticationUtils

      protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils getAuthenticationUtils()
    • setAuthenticationUtils

      @Autowired public void setAuthenticationUtils(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils)
    • getCartApprovalValidationService

      protected CartApprovalValidationService getCartApprovalValidationService()
    • setCartApprovalValidationService

      @Autowired public void setCartApprovalValidationService(CartApprovalValidationService cartApprovalValidationService)
    • getCartStatusManager

      protected CartStatusManager getCartStatusManager()
    • setCartStatusManager

      @Autowired public void setCartStatusManager(CartStatusManager cartStatusManager)