Class CartStalePricingValidationActivity
- java.lang.Object
-
- com.broadleafcommerce.cartoperation.service.checkout.workflow.activity.CartStalePricingValidationActivity
-
- All Implemented Interfaces:
CheckoutWorkflowActivity
public class CartStalePricingValidationActivity extends Object implements CheckoutWorkflowActivity
ThisCheckoutWorkflowActivityis responsible for validating that theCartand itsCartItemshave the actual (latest) prices.- If the prices are accurate, the checkout attempt will continue.
- If the new cart total is less than the previous the cart will be updated with the new prices,
and if the property
shouldRejectLowerPriceis "true" the exceptionCheckoutWorkflowActivityExceptionwill be thrown with theDefaultCheckoutFailureTypes.STALE_CART_PRICING_LOWERfailure type. - If the new cart total is higher than the previous the cart will be updated with the new
prices and the exception
CheckoutWorkflowActivityExceptionwill be thrown with theDefaultCheckoutFailureTypes.STALE_CART_PRICING_HIGHERfailure type.
- Author:
- Dima Myroniuk (dmyroniuk)
-
-
Constructor Summary
Constructors Constructor Description CartStalePricingValidationActivity(org.springframework.context.MessageSource messageSource, CartProvider cartProvider, CartStalePricingValidationActivityProperties properties, StaleCartPricingResultHolder staleCartPricingResultHolder)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected com.broadleafcommerce.cart.client.domain.CartAlertcreateCartAlert(String message)protected com.broadleafcommerce.cart.client.domain.CartdetermineCartWithLatestPrices(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)protected javax.money.MonetaryAmountdetermineOldCartPrice(com.broadleafcommerce.cart.client.domain.Cart cart)com.broadleafcommerce.cart.client.domain.Cartexecute(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String requestId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Method responsible for executing some work against the cart that is required for checkout.protected CartOperationServicegetCartOperationService()protected CartPricingServicegetCartPricingService()Deprecated.since 1.6, usegetCartOperationService()instead.protected CartProvidergetCartProvider()protected StringgetFailureMessage(DefaultCheckoutFailureTypes checkoutFailureTypes)protected org.springframework.context.MessageSourcegetMessageSource()protected StringgetPricingChangeMessage(javax.money.MonetaryAmount oldCartPrice, javax.money.MonetaryAmount latestCartPrice)protected CartStalePricingValidationActivityPropertiesgetProperties()protected StaleCartPricingResultHoldergetStaleCartPricingResultHolder()protected booleanlatestPriceIsHigher(javax.money.MonetaryAmount latestCartPrice, javax.money.MonetaryAmount oldCartPrice)protected booleanlatestPriceIsLower(javax.money.MonetaryAmount latestCartPrice, javax.money.MonetaryAmount oldCartPrice)com.broadleafcommerce.cart.client.domain.Cartrollback(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, String requestId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Method responsible for rolling back any work that was done during the execution of the#execute(Cart, String)method.voidsetCartOperationService(CartOperationService cartOperationService)protected com.broadleafcommerce.cart.client.domain.CartvalidateCartHasLatestPricing(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
-
-
Constructor Detail
-
CartStalePricingValidationActivity
public CartStalePricingValidationActivity(org.springframework.context.MessageSource messageSource, CartProvider cartProvider, CartStalePricingValidationActivityProperties properties, StaleCartPricingResultHolder staleCartPricingResultHolder)
-
-
Method Detail
-
execute
public com.broadleafcommerce.cart.client.domain.Cart execute(@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:CheckoutWorkflowActivityMethod responsible for executing some work against the cart that is required for checkout. This may include, but is not limited to, cart validation checks, inventory reservations, or payment authorizations.- Specified by:
executein interfaceCheckoutWorkflowActivity- Parameters:
cart- TheCartthat we're attempting to checkout with.requestId- The id used to identify changes tied to the specific execution requestcontextInfo- Context information around sandbox and multitenant state.- Returns:
- The final state of the cart following the execution of the activity.
-
rollback
public com.broadleafcommerce.cart.client.domain.Cart rollback(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, String requestId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Description copied from interface:CheckoutWorkflowActivityMethod responsible for rolling back any work that was done during the execution of the#execute(Cart, String)method.- Specified by:
rollbackin interfaceCheckoutWorkflowActivity- Parameters:
cart- TheCartthat we were attempting to checkout with, but ran into an exception/error.requestId- The id used to identify changes tied to the specific execution requestcontextInfo- Context information around sandbox and multitenant state.- Returns:
- The final state of the cart following the rollback of the activity.
-
validateCartHasLatestPricing
protected com.broadleafcommerce.cart.client.domain.Cart validateCartHasLatestPricing(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
determineOldCartPrice
protected javax.money.MonetaryAmount determineOldCartPrice(com.broadleafcommerce.cart.client.domain.Cart cart)
-
determineCartWithLatestPrices
@Nullable protected com.broadleafcommerce.cart.client.domain.Cart determineCartWithLatestPrices(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
latestPriceIsHigher
protected boolean latestPriceIsHigher(javax.money.MonetaryAmount latestCartPrice, javax.money.MonetaryAmount oldCartPrice)
-
latestPriceIsLower
protected boolean latestPriceIsLower(javax.money.MonetaryAmount latestCartPrice, javax.money.MonetaryAmount oldCartPrice)
-
getFailureMessage
protected String getFailureMessage(DefaultCheckoutFailureTypes checkoutFailureTypes)
-
getPricingChangeMessage
protected String getPricingChangeMessage(javax.money.MonetaryAmount oldCartPrice, javax.money.MonetaryAmount latestCartPrice)
-
createCartAlert
protected com.broadleafcommerce.cart.client.domain.CartAlert createCartAlert(String message)
-
getMessageSource
protected org.springframework.context.MessageSource getMessageSource()
-
getCartProvider
protected CartProvider getCartProvider()
-
getCartOperationService
protected CartOperationService getCartOperationService()
-
setCartOperationService
@Autowired public void setCartOperationService(CartOperationService cartOperationService)
-
getProperties
protected CartStalePricingValidationActivityProperties getProperties()
-
getStaleCartPricingResultHolder
protected StaleCartPricingResultHolder getStaleCartPricingResultHolder()
-
getCartPricingService
@Deprecated protected CartPricingService getCartPricingService()
Deprecated.since 1.6, usegetCartOperationService()instead.
-
-