Class DefaultCheckoutService
- All Implemented Interfaces:
CheckoutService
CheckoutService
that is responsible for processing checkout
requests- Author:
- Chad Harchar (charchar), Chris Kittrell (ckittrell)
-
Constructor Summary
ConstructorDescriptionDefaultCheckoutService
(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 void
addCartLinks
(@NonNull com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected CheckoutResponse
buildAwaitingPaymentResultCheckoutResponse
(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aCheckoutResponse
signifying that the checkout submission is awaiting for payment result based on the givenCheckoutProcessDto
.protected com.broadleafcommerce.cart.client.domain.CartActionAudit
buildCartActionAuditForSubmit
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String oldCartStatus) Builds aCartActionAudit
for the submitted accountCart
.protected CheckoutResponse
buildCheckoutResponseBasedOnCartStatus
(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aCheckoutResponse
based on the cart status.protected CheckoutResponse
buildFailedCheckoutResponse
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, @NonNull CartApprovalValidationException e, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected CheckoutResponse
buildFailedCheckoutResponse
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, @NonNull CheckoutException e, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected CheckoutResponse
buildFailedCheckoutResponse
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, @NonNull CheckoutWorkflowException e, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.protected CheckoutResponse
buildFailedCheckoutResponse
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, @NonNull PaymentLockException e, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected CheckoutResponse
buildFailedCheckoutResponse
(@NonNull CheckoutProcessDto processDto, @NonNull RuntimeException exception, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected SendCheckoutEventResponse
buildFailedSendCheckoutEventResponse
(@NonNull String cartId, String failureMessage) Builds a failedSendCheckoutEventResponse
.protected CheckoutResponse
buildSuccessfulCheckoutResponse
(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds a successfulCheckoutResponse
based on the givenCheckoutProcessDto
.protected SendCheckoutEventResponse
buildSuccessSendCheckoutEventResponse
(@NonNull String cartId) Builds a successfulSendCheckoutEventResponse
.protected UpdateCartRequest
buildUpdateCartRequest
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String originalCartStatus) Builds anUpdateCartRequest
based on the given properties.protected void
clearAdjustmentFields
(@NonNull List<com.broadleafcommerce.order.common.domain.Adjustment> adjustments) Clears unneededAdjustment
fields to reduce the payload size.protected String
createOrderNumber
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Creates a new order number for a submitted cart.protected CheckoutProcessDto
finalizeAccountCartIfNecessary
(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finalizes the given accountCart
if necessary.protected com.broadleafcommerce.cart.client.domain.Cart
finalizeCart
(@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 CheckoutProcessDto
finalizeCart
(@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 void
finalizePayments
(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils
protected CartApprovalValidationService
protected com.broadleafcommerce.cart.client.domain.CartLink
getCartItemLink
(@NonNull com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected CartProvider
protected CartStatusValidationHelper
protected com.broadleafcommerce.common.messaging.checkout.CheckoutCompletionProducer
protected CheckoutWorkflow
protected ExternalCartProperties
protected com.broadleafcommerce.cart.client.domain.CartLink
getFulfillmentGroupLink
(@NonNull com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected String
getLatestCheckoutRequestId
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Gets the latest checkout request id for the givenCart
.protected String
getMessage
(@NonNull String errorMessage, Object... args) protected org.springframework.retry.support.RetryTemplate
protected org.springframework.context.MessageSource
protected PaymentProvider<PaymentSummary>
protected org.springframework.retry.support.RetryTemplate
protected StaleCartItemsService
protected com.broadleafcommerce.common.extension.TypeFactory
lockPayments
(@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 void
populateAdjustments
(@NonNull com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart) Populates the cart item, fulfillment item, and fulfillment groupAdjustments
and clear unneeded fields for the givenCheckoutCart
.protected CheckoutProcessDto
prepareCartForCheckout
(@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 CheckoutProcessDto
removeStaleCartItems
(@NonNull CheckoutProcessDto processDto, @NonNull CheckoutException e, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) RemovesCartItems
from theCart
that can no longer be found in the catalog & reprices the cart.resendCartPendingPaymentFailedEvent
(@NonNull String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) ResendCartPendingPaymentFailedEvent
for the given cart id.resendCheckoutCompletionEvent
(@NonNull String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) ResendCheckoutCompletionEvent
for the given cart id.resendCheckoutRollbackEvent
(@NonNull String cartId, @NonNull String requestId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) ResendCheckoutRollbackEvent
for the given cart id.void
sendCartPendingPaymentFailedEvent
(@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 void
sendCheckoutCompletionMessage
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aCheckoutProcessDto
and delegates tosendCheckoutCompletionMessage(CheckoutProcessDto, ContextInfo)
.protected void
sendCheckoutCompletionMessage
(@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 SendCheckoutEventResponse
sendEvent
(@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 void
sendPendingPaymentFailedEventToProvider
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Send theCartPendingPaymentFailedEvent
toCartProvider
for durable sending.void
setAuthenticationUtils
(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils) void
setCartApprovalValidationService
(CartApprovalValidationService cartApprovalValidationService) void
setMessageRetryTemplate
(org.springframework.retry.support.RetryTemplate messageRetryTemplate) void
setPendingPaymentFailedRetryTemplate
(org.springframework.retry.support.RetryTemplate pendingPaymentFailedRetryTemplate) void
setStaleCartItemsService
(StaleCartItemsService staleCartItemsService) protected boolean
shouldResetCartStatus
(@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 void
unlockPayments
(@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.Cart
updateCartStatus
(@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.Cart
updateCartStatus
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String cartStatus, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
validateAccountCartSubmissionIfNecessary
(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) If the givenCart
is an account cart, validates if the cart can be submitted by the givenCustomerRef
.protected void
validateCheckoutRequest
(@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 void
validateCheckoutRequest
(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates the cart for checkoutprotected void
validateRequestId
(@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 givenCart
validateResendCheckoutRollbackEvent
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId) Validates if the checkout rollback event can be resent for the givenCart
validateResendPendingPaymentFailedEvent
(@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:CheckoutService
Process checkout against the providedCheckoutProcessDto
.- Specified by:
processCheckout
in interfaceCheckoutService
- Parameters:
processDto
- TheCheckoutProcessDto
for 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
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.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:CheckoutService
Finalizes checkout for the givenCart
.This is typically used for processes that need to finalize checkout outside the checkout workflow, such as
FinalizeCartAwaitingPaymentResultJobListener
.- Specified by:
finalizeCheckout
in interfaceCheckoutService
- Parameters:
processDto
- theCheckoutProcessDto
containing 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: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 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:CheckoutService
ResendCheckoutCompletionEvent
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 interfaceCheckoutService
- Parameters:
cartId
- the cart id to resend theCheckoutCompletionEvent
forcontextInfo
- 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
ResendCheckoutRollbackEvent
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 interfaceCheckoutService
- Parameters:
cartId
- the cart id to resend theCheckoutRollbackEvent
forrequestId
- the checkout request id to resend theCheckoutRollbackEvent
forcontextInfo
- 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
ResendCartPendingPaymentFailedEvent
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 theCartPendingPaymentFailedEvent
failed to send.- Specified by:
resendCartPendingPaymentFailedEvent
in interfaceCheckoutService
- Parameters:
cartId
- the cart id to resend theCartPendingPaymentFailedEvent
forcontextInfo
- 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 givenCart
- Parameters:
cart
- theCart
used to validate if the event can be resentrequestId
- 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 givenCart
- Parameters:
cart
- theCart
used to validate if the event can be resentrequestId
- 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 givenCart
- Parameters:
cart
- theCart
used to validate if the event can be resentrequestId
- 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 givenTriConsumer
, cart id, andContextInfo
.- Parameters:
validateEventCanResend
- theBiFunction
used to validate if the event can be resent for the cartsendConsumer
- theTriConsumer
used to send the eventcartId
- the cart idcontextInfo
- 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 theCartPendingPaymentFailedEvent
toCartProvider
for 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
- theCart
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 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
- TheCheckoutProcessDto
to validatecontextInfo
- Context information around sandbox and multitenant state.
-
validateRequestId
Validates that the current requestId is not already associated to the cart- Parameters:
processDto
- TheCheckoutProcessDto
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()
andCart.getCheckoutSubmissions()
by default.- Parameters:
processDto
- TheCheckoutProcessDto
containing the cart to prepare for checkoutcontextInfo
- 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 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 theCheckoutWorkflow
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 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
- TheCheckoutProcessDto
that 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) RemovesCartItems
from theCart
that can no longer be found in the catalog & reprices the cart.- Parameters:
processDto
- TheCheckoutProcessDto
that contains the cart with stale cart itemse
- TheCheckoutException
thrown due to the presence of stale cart itemscontextInfo
- 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 requestoriginalCartStatus
- The status of the cart prior to attempting checkoute
- TheCheckoutWorkflowException
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.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
- theCheckoutProcessDto
containing cart that has completed checkout, but needs to be marked as finalizedcontextInfo
- 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 aCheckoutProcessDto
and delegates tosendCheckoutCompletionMessage(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 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
- TheCheckoutProcessDto
containing 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 groupAdjustments
and clear unneeded fields for the givenCheckoutCart
.- Parameters:
checkoutCart
- theCheckoutCart
to populate the adjustments for
-
clearAdjustmentFields
protected void clearAdjustmentFields(@NonNull @NonNull List<com.broadleafcommerce.order.common.domain.Adjustment> adjustments) Clears unneededAdjustment
fields to reduce the payload size.- Parameters:
adjustments
- a list ofAdjustments
to clear the unneeded fields for.
-
buildCheckoutResponseBasedOnCartStatus
protected CheckoutResponse buildCheckoutResponseBasedOnCartStatus(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aCheckoutResponse
based on the cart status.- Parameters:
processDto
- theCheckoutProcessDto
containing the cartcontextInfo
- context information around sandbox and multitenant state- Returns:
- a
CheckoutResponse
based on the cart status
-
buildAwaitingPaymentResultCheckoutResponse
protected CheckoutResponse buildAwaitingPaymentResultCheckoutResponse(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aCheckoutResponse
signifying that the checkout submission is awaiting for payment result based on the givenCheckoutProcessDto
.Delegates to
buildBaseCheckoutResponse(CheckoutProcessDto, boolean, ContextInfo)
by default.- Parameters:
processDto
- theCheckoutProcessDto
to build the baseCheckoutResponse
fromcontextInfo
- context information around sandbox and multitenant state- Returns:
- a successful
CheckoutResponse
based on the givenCheckoutProcessDto
-
buildSuccessfulCheckoutResponse
protected CheckoutResponse buildSuccessfulCheckoutResponse(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds a successfulCheckoutResponse
based on the givenCheckoutProcessDto
.Delegates to
buildBaseCheckoutResponse(CheckoutProcessDto, boolean, ContextInfo)
by default.- Parameters:
processDto
- theCheckoutProcessDto
to build the baseCheckoutResponse
fromcontextInfo
- context information around sandbox and multitenant state- Returns:
- a successful
CheckoutResponse
based 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
- theCheckoutProcessDto
to build the baseCheckoutResponse
fromexception
- theRuntimeException
contextInfo
- context information around sandbox and multitenant state- Returns:
- a failed
CheckoutResponse
based on the givenCheckoutProcessDto
andRuntimeException
-
getMessage
-
validateAccountCartSubmissionIfNecessary
protected void validateAccountCartSubmissionIfNecessary(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) If the givenCart
is 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
- theCheckoutProcessDto
containing 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 accountCart
if necessary.By default, this method just updates the approver email. Any custom logic should be added here.
- Parameters:
processDto
- theCheckoutProcessDto
containing 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 anUpdateCartRequest
based on the given properties.- Parameters:
cart
- theCart
to updateoriginalCartStatus
- the originalCart.getStatus()
prior checkout submission- Returns:
- an
UpdateCartRequest
based 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 aCartActionAudit
for the submitted accountCart
.By default, only approvers can submit account carts.
- Parameters:
cart
- the accountCart
that 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)