Class CartStalePricingValidationActivity
- java.lang.Object
-
- com.broadleafcommerce.cartoperation.service.checkout.workflow.activity.CartStalePricingValidationActivity
-
- All Implemented Interfaces:
CheckoutWorkflowActivity
public class CartStalePricingValidationActivity extends Object implements CheckoutWorkflowActivity
ThisCheckoutWorkflowActivity
is responsible for validating that theCart
and itsCartItems
have 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
shouldRejectLowerPrice
is "true" the exceptionCheckoutWorkflowActivityException
will be thrown with theDefaultCheckoutFailureTypes.STALE_CART_PRICING_LOWER
failure type. - If the new cart total is higher than the previous the cart will be updated with the new
prices and the exception
CheckoutWorkflowActivityException
will be thrown with theDefaultCheckoutFailureTypes.STALE_CART_PRICING_HIGHER
failure 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.CartAlert
createCartAlert(String message)
protected com.broadleafcommerce.cart.client.domain.Cart
determineCartWithLatestPrices(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected javax.money.MonetaryAmount
determineOldCartPrice(com.broadleafcommerce.cart.client.domain.Cart cart)
com.broadleafcommerce.cart.client.domain.Cart
execute(@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 CartOperationService
getCartOperationService()
protected CartPricingService
getCartPricingService()
Deprecated.since 1.6, usegetCartOperationService()
instead.protected CartProvider
getCartProvider()
protected String
getFailureMessage(DefaultCheckoutFailureTypes checkoutFailureTypes)
protected org.springframework.context.MessageSource
getMessageSource()
protected String
getPricingChangeMessage(javax.money.MonetaryAmount oldCartPrice, javax.money.MonetaryAmount latestCartPrice)
protected CartStalePricingValidationActivityProperties
getProperties()
protected StaleCartPricingResultHolder
getStaleCartPricingResultHolder()
protected boolean
latestPriceIsHigher(javax.money.MonetaryAmount latestCartPrice, javax.money.MonetaryAmount oldCartPrice)
protected boolean
latestPriceIsLower(javax.money.MonetaryAmount latestCartPrice, javax.money.MonetaryAmount oldCartPrice)
com.broadleafcommerce.cart.client.domain.Cart
rollback(@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.void
setCartOperationService(CartOperationService cartOperationService)
protected com.broadleafcommerce.cart.client.domain.Cart
validateCartHasLatestPricing(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:CheckoutWorkflowActivity
Method 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:
execute
in interfaceCheckoutWorkflowActivity
- Parameters:
cart
- TheCart
that 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:CheckoutWorkflowActivity
Method responsible for rolling back any work that was done during the execution of the#execute(Cart, String)
method.- Specified by:
rollback
in interfaceCheckoutWorkflowActivity
- Parameters:
cart
- TheCart
that 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.
-
-