Class DefaultCheckoutWorkflow
java.lang.Object
com.broadleafcommerce.cartoperation.service.checkout.workflow.DefaultCheckoutWorkflow
- All Implemented Interfaces:
CheckoutWorkflow
- Author:
- Chris Kittrell (ckittrell)
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDefaultCheckoutWorkflow
(List<CheckoutWorkflowActivity> workflowActivities, CheckoutRollbackEventProducer checkoutRollbackEventProducer, CartProvider cartProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory, org.springframework.context.MessageSource messageSource) -
Method Summary
Modifier and TypeMethodDescriptionprotected String
buildWorkflowErrorMessage
(@NonNull Exception e) execute
(@NonNull CheckoutProcessDto processDto, @NonNull Map<String, String> securityCodes, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Method used to coordinate the execution ofCheckoutWorkflowActivities
.protected CheckoutProcessDto
executeActivity
(@NonNull CheckoutWorkflowActivity activity, @NonNull CheckoutProcessDto processDto, @NonNull Map<String, String> securityCodes, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected CartProvider
protected CheckoutRollbackEventProducer
getCheckoutWorkflowErrors
(@NonNull Map<String, Object> cartInternalAttributes) getCheckoutWorkflowRollbackErrors
(@NonNull Map<String, Object> cartInternalAttributes) protected String
protected ExternalPaymentTransactionProperties
protected org.springframework.retry.support.RetryTemplate
protected org.springframework.context.MessageSource
protected com.fasterxml.jackson.databind.ObjectMapper
getPaymentFinalizationTimestamps
(@NonNull Map<String, Object> cartInternalAttributes) protected List<PaymentFinalizationActivity>
protected PaymentPatternProperties
protected PaymentProvider<PaymentSummary>
getPaymentTransactionFailureMessages
(@NonNull List<PaymentTransactionFailureDetail> failureDetails) protected com.broadleafcommerce.common.extension.TypeFactory
protected List<CheckoutWorkflowActivity>
protected List<? extends CheckoutWorkflowActivity>
getWorkflowActivities
(@NonNull CheckoutProcessDto processDto) protected void
logErrorInitiatingWorkflowRollback
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, @NonNull CheckoutWorkflowActivityException e) protected void
logErrorInitiatingWorkflowRollback
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, Exception e) Log a message to record the initiation of the workflow rollbackprotected void
recordPaymentFinalizationTimestamp
(@NonNull CheckoutProcessDto processDto) protected CheckoutProcessDto
recordRollbackError
(@NonNull CheckoutProcessDto processDto, @NonNull Exception e, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Method responsible for recording the error that was encountered during the activity's rollback.protected CheckoutProcessDto
recordWorkflowError
(@NonNull CheckoutProcessDto processDto, @NonNull CheckoutWorkflowActivityException workflowActivityException, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Method responsible for recording the error that was encountered during the activity's execution.rollback
(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Method used to coordinate the rollback of work that has been done by theCheckoutWorkflowActivities
up to that point.void
sendCheckoutRollbackEvent
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Send a message to notify external services (and internal listeners) of the checkout workflow rollback, so that they can react accordingly.void
setExternalPaymentTransactionProperties
(ExternalPaymentTransactionProperties externalPaymentTransactionProperties) void
setMessageRetryTemplate
(org.springframework.retry.support.RetryTemplate messageRetryTemplate) void
setObjectMapper
(com.fasterxml.jackson.databind.ObjectMapper objectMapper) void
setPaymentFinalizationWorkflowActivities
(List<PaymentFinalizationActivity> paymentFinalizationWorkflowActivities) void
setPaymentPatternProperties
(PaymentPatternProperties paymentPatternProperties) void
setPaymentProvider
(PaymentProvider<PaymentSummary> paymentProvider) protected boolean
shouldEnterAwaitingPaymentFinalizationCartStatus
(@NonNull CheckoutProcessDto processDto, @NonNull CheckoutWorkflowActivityException e, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
unlockPayments
(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected CheckoutProcessDto
updateCartStatusForPaymentFailures
(@NonNull CheckoutProcessDto processDto, @NonNull CheckoutWorkflowActivityException e, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
Field Details
-
CHECKOUT_WORKFLOW_ERRORS
- See Also:
-
PAYMENT_FINALIZATION_TIMESTAMPS
- See Also:
-
CHECKOUT_WORKFLOW_ROLLBACK_ERRORS
- See Also:
-
-
Constructor Details
-
DefaultCheckoutWorkflow
public DefaultCheckoutWorkflow(List<CheckoutWorkflowActivity> workflowActivities, CheckoutRollbackEventProducer checkoutRollbackEventProducer, CartProvider cartProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory, org.springframework.context.MessageSource messageSource)
-
-
Method Details
-
execute
public CheckoutProcessDto execute(@NonNull @NonNull CheckoutProcessDto processDto, @NonNull @NonNull Map<String, String> securityCodes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CheckoutWorkflow
Method used to coordinate the execution ofCheckoutWorkflowActivities
. If there is an exception/error during the execution of those activities, thenCheckoutWorkflow.rollback(CheckoutProcessDto, ContextInfo)
should be called to un-do the work that had been done up to the point of the exception/error.- Specified by:
execute
in interfaceCheckoutWorkflow
- Parameters:
processDto
- TheCheckoutProcessDto
that we're attempting to checkout with.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 final state of the
CheckoutProcessDto
following the execution of the workflow.
-
getWorkflowActivities
protected List<? extends CheckoutWorkflowActivity> getWorkflowActivities(@NonNull @NonNull CheckoutProcessDto processDto) -
updateCartStatusForPaymentFailures
protected CheckoutProcessDto updateCartStatusForPaymentFailures(@NonNull @NonNull CheckoutProcessDto processDto, @NonNull @NonNull CheckoutWorkflowActivityException e, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
shouldEnterAwaitingPaymentFinalizationCartStatus
protected boolean shouldEnterAwaitingPaymentFinalizationCartStatus(@NonNull @NonNull CheckoutProcessDto processDto, @NonNull @NonNull CheckoutWorkflowActivityException e, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
recordPaymentFinalizationTimestamp
-
getPaymentFinalizationTimestamps
-
getCurrentTimestamp
-
unlockPayments
protected void unlockPayments(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
rollback
public CheckoutProcessDto rollback(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CheckoutWorkflow
Method used to coordinate the rollback of work that has been done by theCheckoutWorkflowActivities
up to that point.- Specified by:
rollback
in interfaceCheckoutWorkflow
- Parameters:
processDto
- TheCheckoutProcessDto
that we were attempting to checkout with, but ran into an exception/error.contextInfo
- Context information around sandbox and multitenant state.- Returns:
- The final state of the
CheckoutProcessDto
following the execution of the workflow rollback.
-
sendCheckoutRollbackEvent
public void sendCheckoutRollbackEvent(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CheckoutWorkflow
Send a message to notify external services (and internal listeners) of the checkout workflow rollback, so that they can react accordingly.- Specified by:
sendCheckoutRollbackEvent
in interfaceCheckoutWorkflow
- Parameters:
cart
- The cart that is being rolled back.requestId
- The checkout request idcontextInfo
- Context information around sandbox and multitenant state.
-
logErrorInitiatingWorkflowRollback
protected void logErrorInitiatingWorkflowRollback(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId, Exception e) Log a message to record the initiation of the workflow rollback- Parameters:
cart
- The cart that is being acted upon in this workflowrequestId
- The id used to identify changes tied to the specific execution requeste
- The exception thrown by theCheckoutWorkflowActivity
-
executeActivity
protected CheckoutProcessDto executeActivity(@NonNull @NonNull CheckoutWorkflowActivity activity, @NonNull @NonNull CheckoutProcessDto processDto, @NonNull @NonNull Map<String, String> securityCodes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
logErrorInitiatingWorkflowRollback
protected void logErrorInitiatingWorkflowRollback(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String requestId, @NonNull @NonNull CheckoutWorkflowActivityException e) -
recordWorkflowError
protected CheckoutProcessDto recordWorkflowError(@NonNull @NonNull CheckoutProcessDto processDto, @NonNull @NonNull CheckoutWorkflowActivityException workflowActivityException, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Method responsible for recording the error that was encountered during the activity's execution.- Parameters:
processDto
- TheCheckoutProcessDto
that is being acted upon in this workflowworkflowActivityException
- The exception thrown by theCheckoutWorkflowActivity
contextInfo
- Context information around sandbox and multitenant state.- Returns:
- The cart including the recorded activity execution state
-
getCheckoutWorkflowErrors
-
buildWorkflowErrorMessage
-
recordRollbackError
protected CheckoutProcessDto recordRollbackError(@NonNull @NonNull CheckoutProcessDto processDto, @NonNull @NonNull Exception e, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Method responsible for recording the error that was encountered during the activity's rollback.- Parameters:
processDto
- TheCheckoutProcessDto
that encountered an error during the execution of this activitye
- The exception that was encounteredcontextInfo
- Context information around sandbox and multitenant state.- Returns:
- The
CheckoutProcessDto
including the recorded activity rollback state
-
getCheckoutWorkflowRollbackErrors
-
getPaymentTransactionFailureMessages
protected List<String> getPaymentTransactionFailureMessages(@NonNull @NonNull List<PaymentTransactionFailureDetail> failureDetails) -
getWorkflowActivities
-
setPaymentFinalizationWorkflowActivities
@Autowired(required=false) public void setPaymentFinalizationWorkflowActivities(List<PaymentFinalizationActivity> paymentFinalizationWorkflowActivities) -
getPaymentFinalizationWorkflowActivities
-
getCheckoutRollbackEventProducer
-
getCartProvider
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getMessageSource
protected org.springframework.context.MessageSource getMessageSource() -
setPaymentProvider
-
getPaymentProvider
-
setExternalPaymentTransactionProperties
@Autowired(required=false) public void setExternalPaymentTransactionProperties(@Nullable ExternalPaymentTransactionProperties externalPaymentTransactionProperties) -
getExternalPaymentTransactionProperties
-
setPaymentPatternProperties
@Autowired public void setPaymentPatternProperties(PaymentPatternProperties paymentPatternProperties) -
getPaymentPatternProperties
-
setMessageRetryTemplate
@Autowired @Qualifier("checkoutWorkflowRollbackMessageRetryTemplate") public void setMessageRetryTemplate(org.springframework.retry.support.RetryTemplate messageRetryTemplate) -
getMessageRetryTemplate
protected org.springframework.retry.support.RetryTemplate getMessageRetryTemplate() -
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
setObjectMapper
@Autowired public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-