Class DefaultCheckoutService
- All Implemented Interfaces:
CheckoutService
CheckoutService that is responsible for processing checkout
requests- Author:
- Chad Harchar (charchar), Chris Kittrell (ckittrell)
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultCheckoutService(CartStatusValidationHelper cartStatusValidationHelper, CheckoutWorkflow checkoutWorkflow, CartProvider cartProvider, com.broadleafcommerce.common.messaging.checkout.CheckoutCompletionProducer checkoutCompletionProducer, ExternalCartProperties externalCartProperties, PaymentProvider<PaymentSummary> paymentProvider, org.springframework.context.MessageSource messageSource, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCartLinks(@NonNull com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected CheckoutResponsebuildAwaitingPaymentResultCheckoutResponse(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aCheckoutResponsesignifying that the checkout submission is awaiting for payment result based on the givenCheckoutProcessDto.protected com.broadleafcommerce.cart.client.domain.CartActionAuditbuildCartActionAuditForSubmit(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String oldCartStatus) Builds aCartActionAuditfor the submitted accountCart.protected CheckoutResponsebuildCheckoutResponseBasedOnCartStatus(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aCheckoutResponsebased on the cart status.protected CheckoutResponsebuildFailedCheckoutResponse(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, @NonNull CartApprovalValidationException e, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected CheckoutResponsebuildFailedCheckoutResponse(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, @NonNull CheckoutException e, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected CheckoutResponsebuildFailedCheckoutResponse(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, @NonNull CheckoutWorkflowException e, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.protected CheckoutResponsebuildFailedCheckoutResponse(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, @NonNull PaymentLockException e, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected CheckoutResponsebuildFailedCheckoutResponse(@NonNull CheckoutProcessDto processDto, @NonNull RuntimeException exception, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected SendCheckoutEventResponsebuildFailedSendCheckoutEventResponse(@NonNull String cartId, String failureMessage) Builds a failedSendCheckoutEventResponse.protected CheckoutResponsebuildSuccessfulCheckoutResponse(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds a successfulCheckoutResponsebased on the givenCheckoutProcessDto.protected SendCheckoutEventResponsebuildSuccessSendCheckoutEventResponse(@NonNull String cartId) Builds a successfulSendCheckoutEventResponse.protected UpdateCartRequestbuildUpdateCartRequest(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String originalCartStatus) Builds anUpdateCartRequestbased on the given properties.protected voidclearAdjustmentFields(@NonNull List<com.broadleafcommerce.order.common.domain.Adjustment> adjustments) Clears unneededAdjustmentfields to reduce the payload size.protected StringcreateOrderNumber(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Creates a new order number for a submitted cart.protected CheckoutProcessDtofinalizeAccountCartIfNecessary(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finalizes the given accountCartif necessary.protected com.broadleafcommerce.cart.client.domain.CartfinalizeCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull Map<String, String> paymentLockTokens, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated, for removal: This API element is subject to removal in a future version.since 1.8.0, in favor offinalizeCart(CheckoutProcessDto, ContextInfo)protected CheckoutProcessDtofinalizeCart(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Following a successful checkout, this method is responsible for recording the finalized state of the cart.finalizeCheckout(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finalizes checkout for the givenCart.protected voidfinalizePayments(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtilsprotected CartApprovalValidationServiceprotected com.broadleafcommerce.cart.client.domain.CartLinkgetCartItemLink(@NonNull com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected CartProviderprotected CartStatusValidationHelperprotected com.broadleafcommerce.common.messaging.checkout.CheckoutCompletionProducerprotected CheckoutWorkflowprotected ExternalCartPropertiesprotected com.broadleafcommerce.cart.client.domain.CartLinkgetFulfillmentGroupLink(@NonNull com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected StringgetLatestCheckoutRequestId(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Gets the latest checkout request id for the givenCart.protected StringgetMessage(@NonNull String errorMessage, Object... args) protected org.springframework.retry.support.RetryTemplateprotected org.springframework.context.MessageSourceprotected PaymentProvider<PaymentSummary>protected org.springframework.retry.support.RetryTemplateprotected StaleCartItemsServiceprotected com.broadleafcommerce.common.extension.TypeFactorylockPayments(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, 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 oflockAndRetrievePayments(CheckoutProcessDto, ContextInfo)protected voidpopulateAdjustments(@NonNull com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart) Populates the cart item, fulfillment item, and fulfillment groupAdjustmentsand clear unneeded fields for the givenCheckoutCart.protected CheckoutProcessDtoprepareCartForCheckout(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Prepares the cart for checkout.processCheckout(@NonNull CheckoutProcessDto processDto, @NonNull Map<String, String> securityCodes, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Process checkout against the providedCheckoutProcessDto.protected CheckoutProcessDtoremoveStaleCartItems(@NonNull CheckoutProcessDto processDto, @NonNull CheckoutException e, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) RemovesCartItemsfrom theCartthat can no longer be found in the catalog & reprices the cart.resendCartPendingPaymentFailedEvent(@NonNull String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) ResendCartPendingPaymentFailedEventfor the given cart id.resendCheckoutCompletionEvent(@NonNull String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) ResendCheckoutCompletionEventfor the given cart id.resendCheckoutRollbackEvent(@NonNull String cartId, @NonNull String requestId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) ResendCheckoutRollbackEventfor the given cart id.voidsendCartPendingPaymentFailedEvent(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Send a message to notify external services (and internal listeners) of the cart pending payment failed, so that they can react accordingly.protected voidsendCheckoutCompletionMessage(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aCheckoutProcessDtoand delegates tosendCheckoutCompletionMessage(CheckoutProcessDto, ContextInfo).protected voidsendCheckoutCompletionMessage(@NonNull CheckoutProcessDto processDto, 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.protected SendCheckoutEventResponsesendEvent(@NonNull BiFunction<com.broadleafcommerce.cart.client.domain.Cart, String, org.apache.commons.lang3.tuple.Pair<Boolean, String>> validateEventCanResend, @NonNull org.apache.camel.util.function.TriConsumer<com.broadleafcommerce.cart.client.domain.Cart, String, com.broadleafcommerce.data.tracking.core.context.ContextInfo> sendConsumer, String cartId, String requestId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sends the event with the givenTriConsumer, cart id, andContextInfo.protected voidsendPendingPaymentFailedEventToProvider(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Send theCartPendingPaymentFailedEventtoCartProviderfor durable sending.voidsetAuthenticationUtils(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils) voidsetCartApprovalValidationService(CartApprovalValidationService cartApprovalValidationService) voidsetMessageRetryTemplate(org.springframework.retry.support.RetryTemplate messageRetryTemplate) voidsetPendingPaymentFailedRetryTemplate(org.springframework.retry.support.RetryTemplate pendingPaymentFailedRetryTemplate) voidsetStaleCartItemsService(StaleCartItemsService staleCartItemsService) protected booleanshouldResetCartStatus(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String originalCartStatus, @NonNull RuntimeException e) Determines whether or not the cart's status should be reset after encountering an unexpected exception during checkout.protected voidunlockPayments(@NonNull CheckoutProcessDto processDto, 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 viaPaymentProvider.lockAndRetrieveCartPayments(Cart, ContextInfo).protected com.broadleafcommerce.cart.client.domain.CartupdateCartStatus(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String cartStatus, boolean updateCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected com.broadleafcommerce.cart.client.domain.CartupdateCartStatus(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String cartStatus, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidvalidateAccountCartSubmissionIfNecessary(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) If the givenCartis an account cart, validates if the cart can be submitted by the givenCustomerRef.protected voidvalidateCheckoutRequest(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId) Deprecated, for removal: This API element is subject to removal in a future version.since 1.8.0, in favor ofvalidateCheckoutRequest(CheckoutProcessDto, ContextInfo)protected voidvalidateCheckoutRequest(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates the cart for checkoutprotected voidvalidateRequestId(@NonNull CheckoutProcessDto processDto) Validates that the current requestId is not already associated to the cartvalidateResendCheckoutCompletionEvent(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, String requestId) Validates if the checkout completion event can be resent for the givenCartvalidateResendCheckoutRollbackEvent(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId) Validates if the checkout rollback event can be resent for the givenCartvalidateResendPendingPaymentFailedEvent(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, String requestId) Validates if the pending payment failed event can be resent for the givenCart
-
Constructor Details
-
DefaultCheckoutService
public DefaultCheckoutService(CartStatusValidationHelper cartStatusValidationHelper, CheckoutWorkflow checkoutWorkflow, CartProvider cartProvider, com.broadleafcommerce.common.messaging.checkout.CheckoutCompletionProducer checkoutCompletionProducer, ExternalCartProperties externalCartProperties, PaymentProvider<PaymentSummary> paymentProvider, org.springframework.context.MessageSource messageSource, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
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:CheckoutServiceProcess checkout against the providedCheckoutProcessDto.- Specified by:
processCheckoutin interfaceCheckoutService- Parameters:
processDto- TheCheckoutProcessDtofor processing checkoutsecurityCodes- Secure codes that are passed to the gateway for verification during authorization or capture transactionscontextInfo- Context information around sandbox and multitenant state- Returns:
- The
CheckoutResponsecontaining 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.since 1.8.0, in favor ofvalidateCheckoutRequest(CheckoutProcessDto, ContextInfo)Validates the cart for checkout.- Parameters:
cart- The cart to validaterequestId- 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:CheckoutServiceFinalizes checkout for the givenCart.This is typically used for processes that need to finalize checkout outside the checkout workflow, such as
FinalizeCartAwaitingPaymentResultJobListener.- Specified by:
finalizeCheckoutin interfaceCheckoutService- Parameters:
processDto- theCheckoutProcessDtocontaining the cart to finalizecontextInfo- Context information around sandbox and multitenant state.- Returns:
- the finalized
CheckoutProcessDto
-
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:CheckoutServiceSend a message to notify external services (and internal listeners) of the cart pending payment failed, so that they can react accordingly.- Specified by:
sendCartPendingPaymentFailedEventin interfaceCheckoutService- 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:CheckoutServiceResendCheckoutCompletionEventfor the given cart id.This is useful to manually recover from scenarios where the cart was finalized for checkout but the
CheckoutCompletionEventfailed to send.- Specified by:
resendCheckoutCompletionEventin interfaceCheckoutService- Parameters:
cartId- the cart id to resend theCheckoutCompletionEventforcontextInfo- context information around sandbox and multitenant state- Returns:
- a
SendCheckoutEventResponsecontaining 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:CheckoutServiceResendCheckoutRollbackEventfor the given cart id.This is useful to manually recover from scenarios where the cart was rolled back but the
CheckoutRollbackEventfailed to send.- Specified by:
resendCheckoutRollbackEventin interfaceCheckoutService- Parameters:
cartId- the cart id to resend theCheckoutRollbackEventforrequestId- the checkout request id to resend theCheckoutRollbackEventforcontextInfo- context information around sandbox and multitenant state- Returns:
- a
SendCheckoutEventResponsecontaining 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:CheckoutServiceResendCartPendingPaymentFailedEventfor the given cart id.This is useful to manually recover from scenarios where the cart status was updated to
DefaultCartStatuses.PENDING_PAYMENT_FAILEDbut theCartPendingPaymentFailedEventfailed to send.- Specified by:
resendCartPendingPaymentFailedEventin interfaceCheckoutService- Parameters:
cartId- the cart id to resend theCartPendingPaymentFailedEventforcontextInfo- context information around sandbox and multitenant state- Returns:
- a
SendCheckoutEventResponsecontaining 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 givenCart- Parameters:
cart- theCartused to validate if the event can be resentrequestId- the checkout request id- Returns:
- a
Pairwith 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 givenCart- Parameters:
cart- theCartused to validate if the event can be resentrequestId- the checkout request id- Returns:
- a
Pairwith 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 givenCart- Parameters:
cart- theCartused to validate if the event can be resentrequestId- the checkout request id- Returns:
- a
Pairwith 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 givenTriConsumer, cart id, andContextInfo.- Parameters:
validateEventCanResend- theBiFunctionused to validate if the event can be resent for the cartsendConsumer- theTriConsumerused to send the eventcartId- the cart idcontextInfo- context information around sandbox and multitenant state- Returns:
- a
SendCheckoutEventResponsecontaining 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 theCartPendingPaymentFailedEventtoCartProviderfor durable sending.- Parameters:
cart- The cart that is being evaluated for checkout.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 givenCart.- Parameters:
cart- theCartto 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 successfulSendCheckoutEventResponse.- 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 failedSendCheckoutEventResponse.- Parameters:
cartId- the cart id that was requested to send the eventfailureMessage- 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- TheCheckoutProcessDtoto validatecontextInfo- Context information around sandbox and multitenant state.
-
validateRequestId
Validates that the current requestId is not already associated to the cart- Parameters:
processDto- TheCheckoutProcessDtocontaining 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()andCart.getCheckoutSubmissions()by default.- Parameters:
processDto- TheCheckoutProcessDtocontaining the cart to prepare for checkoutcontextInfo- Context information around sandbox and multitenant state- Returns:
- the
CheckoutProcessDtocontaining 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 oflockAndRetrievePayments(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 theCheckoutWorkflowand 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 lockedcontextInfo- 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 viaPaymentProvider.lockAndRetrieveCartPayments(Cart, ContextInfo).- Parameters:
processDto- TheCheckoutProcessDtothat contains a map of payment id to lock token that was previously obtained by callingPaymentProvider.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) RemovesCartItemsfrom theCartthat can no longer be found in the catalog & reprices the cart.- Parameters:
processDto- TheCheckoutProcessDtothat contains the cart with stale cart itemse- TheCheckoutExceptionthrown due to the presence of stale cart itemscontextInfo- context information around sandbox and multitenant state- Returns:
- The updated
CheckoutProcessDtocontaining 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 requestoriginalCartStatus- The status of the cart prior to attempting checkoute- TheCheckoutWorkflowExceptionthat 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.since 1.8.0, in favor offinalizeCart(CheckoutProcessDto, ContextInfo)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 finalizedpaymentLockTokens- 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- theCheckoutProcessDtocontaining cart that has completed checkout, but needs to be marked as finalizedcontextInfo- context information around sandbox and multitenant state- Returns:
- The
CheckoutProcessDtocontaining 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 aCheckoutProcessDtoand delegates tosendCheckoutCompletionMessage(CheckoutProcessDto, ContextInfo).Useful to send
CheckoutCompletionEventoutside 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 idcontextInfo- 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- TheCheckoutProcessDtocontaining details about the successful checkoutcontextInfo- Context information around sandbox and multitenant state.
-
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 groupAdjustmentsand clear unneeded fields for the givenCheckoutCart.- Parameters:
checkoutCart- theCheckoutCartto populate the adjustments for
-
clearAdjustmentFields
protected void clearAdjustmentFields(@NonNull @NonNull List<com.broadleafcommerce.order.common.domain.Adjustment> adjustments) Clears unneededAdjustmentfields to reduce the payload size.- Parameters:
adjustments- a list ofAdjustmentsto clear the unneeded fields for.
-
buildCheckoutResponseBasedOnCartStatus
protected CheckoutResponse buildCheckoutResponseBasedOnCartStatus(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aCheckoutResponsebased on the cart status.- Parameters:
processDto- theCheckoutProcessDtocontaining the cartcontextInfo- context information around sandbox and multitenant state- Returns:
- a
CheckoutResponsebased on the cart status
-
buildAwaitingPaymentResultCheckoutResponse
protected CheckoutResponse buildAwaitingPaymentResultCheckoutResponse(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aCheckoutResponsesignifying that the checkout submission is awaiting for payment result based on the givenCheckoutProcessDto.Delegates to
buildBaseCheckoutResponse(CheckoutProcessDto, boolean, ContextInfo)by default.- Parameters:
processDto- theCheckoutProcessDtoto build the baseCheckoutResponsefromcontextInfo- context information around sandbox and multitenant state- Returns:
- a successful
CheckoutResponsebased on the givenCheckoutProcessDto
-
buildSuccessfulCheckoutResponse
protected CheckoutResponse buildSuccessfulCheckoutResponse(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds a successfulCheckoutResponsebased on the givenCheckoutProcessDto.Delegates to
buildBaseCheckoutResponse(CheckoutProcessDto, boolean, ContextInfo)by default.- Parameters:
processDto- theCheckoutProcessDtoto build the baseCheckoutResponsefromcontextInfo- context information around sandbox and multitenant state- Returns:
- a successful
CheckoutResponsebased on the givenCheckoutProcessDto
-
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) Deprecated. -
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) - Parameters:
processDto- theCheckoutProcessDtoto build the baseCheckoutResponsefromexception- theRuntimeExceptioncontextInfo- context information around sandbox and multitenant state- Returns:
- a failed
CheckoutResponsebased on the givenCheckoutProcessDtoandRuntimeException
-
getMessage
-
validateAccountCartSubmissionIfNecessary
protected void validateAccountCartSubmissionIfNecessary(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) If the givenCartis an account cart, validates if the cart can be submitted by the givenCustomerRef.By default, only customers with valid permissions can submit account carts.
- Parameters:
processDto- theCheckoutProcessDtocontaining the cart and customer ref to validatecontextInfo- context information around sandbox and multitenant state
-
finalizeAccountCartIfNecessary
protected CheckoutProcessDto finalizeAccountCartIfNecessary(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finalizes the given accountCartif necessary.By default, this method just updates the approver email. Any custom logic should be added here.
- Parameters:
processDto- theCheckoutProcessDtocontaining the account cart that was submittedcontextInfo- 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 anUpdateCartRequestbased on the given properties.- Parameters:
cart- theCartto updateoriginalCartStatus- the originalCart.getStatus()prior checkout submission- Returns:
- an
UpdateCartRequestbased on the given properties
-
buildCartActionAuditForSubmit
protected com.broadleafcommerce.cart.client.domain.CartActionAudit buildCartActionAuditForSubmit(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String oldCartStatus) Builds aCartActionAuditfor the submitted accountCart.By default, only approvers can submit account carts.
- Parameters:
cart- the accountCartthat was submittedoldCartStatus- the oldCart.getStatus()
-
getCartStatusValidationHelper
-
getCheckoutWorkflow
-
getCartProvider
-
getCheckoutCompletionProducer
protected com.broadleafcommerce.common.messaging.checkout.CheckoutCompletionProducer getCheckoutCompletionProducer() -
getExternalCartProperties
-
getPaymentProvider
-
getMessageSource
protected org.springframework.context.MessageSource getMessageSource() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
setStaleCartItemsService
-
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
-
setCartApprovalValidationService
@Autowired public void setCartApprovalValidationService(CartApprovalValidationService cartApprovalValidationService)
-
buildFailedCheckoutResponse(Cart, String, CheckoutException, ContextInfo)