Class CartStalePricingValidationActivity
java.lang.Object
com.broadleafcommerce.cartoperation.service.checkout.workflow.activity.CartStalePricingValidationActivity
- All Implemented Interfaces:
CheckoutWorkflowActivity
,RequiresSecurePaymentInformationActivity
public class CartStalePricingValidationActivity
extends Object
implements RequiresSecurePaymentInformationActivity
This
CheckoutWorkflowActivity
is responsible for validating that the Cart
and its
CartItems
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
ConstructorDescriptionCartStalePricingValidationActivity
(org.springframework.context.MessageSource messageSource, CartProvider cartProvider, CartStalePricingValidationActivityProperties properties, StaleCartPricingResultHolder staleCartPricingResultHolder) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.broadleafcommerce.cart.client.domain.CartAlert
createCartAlert
(@NonNull String message) protected com.broadleafcommerce.cart.client.domain.Cart
determineCartWithLatestPrices
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected javax.money.MonetaryAmount
determineOldCartPrice
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) execute
(@NonNull CheckoutProcessDto processDto, @NonNull Map<String, String> securityCodes, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Method responsible for executing some work against the cart that requires secure payment information in checkout.protected CartOperationService
protected CartOperationServiceProperties
protected CartPricingService
Deprecated.protected CartProvider
protected String
getFailureMessage
(@NonNull DefaultCheckoutFailureTypes checkoutFailureTypes) protected org.springframework.context.MessageSource
protected String
getPricingChangeMessage
(@NonNull javax.money.MonetaryAmount oldCartPrice, @NonNull javax.money.MonetaryAmount latestCartPrice) protected StaleCartPricingResultHolder
protected com.broadleafcommerce.common.extension.TypeFactory
protected boolean
lastCatalogRepriceIsStale
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Determines if the period between now and the cart's last catalog reprice has exceeded the time-to-live defined inCartOperationServiceProperties.getCartPricingTimeToLive()
.protected boolean
latestPriceIsHigher
(@NonNull javax.money.MonetaryAmount latestCartPrice, @NonNull javax.money.MonetaryAmount oldCartPrice) protected boolean
latestPriceIsLower
(@NonNull javax.money.MonetaryAmount latestCartPrice, @NonNull javax.money.MonetaryAmount oldCartPrice) rollback
(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Method responsible for rolling back any work that was done during the execution of theCheckoutWorkflowActivity.execute(CheckoutProcessDto, ContextInfo)
method.void
setCartOperationService
(CartOperationService cartOperationService) void
setCartOperationServiceProperties
(CartOperationServiceProperties cartOperationServiceProperties) void
setTypeFactory
(com.broadleafcommerce.common.extension.TypeFactory typeFactory) protected CheckoutProcessDto
validateCartHasLatestPricing
(@NonNull CheckoutProcessDto processDto, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.cartoperation.service.checkout.workflow.activity.RequiresSecurePaymentInformationActivity
execute
-
Constructor Details
-
CartStalePricingValidationActivity
public CartStalePricingValidationActivity(org.springframework.context.MessageSource messageSource, CartProvider cartProvider, CartStalePricingValidationActivityProperties properties, StaleCartPricingResultHolder staleCartPricingResultHolder)
-
-
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:RequiresSecurePaymentInformationActivity
Method responsible for executing some work against the cart that requires secure payment information in checkout.- Specified by:
execute
in interfaceRequiresSecurePaymentInformationActivity
- 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 activity.
-
rollback
public CheckoutProcessDto rollback(@NonNull @NonNull CheckoutProcessDto processDto, @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 theCheckoutWorkflowActivity.execute(CheckoutProcessDto, ContextInfo)
method.- Specified by:
rollback
in interfaceCheckoutWorkflowActivity
- 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 rollback of the activity.
-
validateCartHasLatestPricing
protected CheckoutProcessDto validateCartHasLatestPricing(@NonNull @NonNull CheckoutProcessDto processDto, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
lastCatalogRepriceIsStale
protected boolean lastCatalogRepriceIsStale(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Determines if the period between now and the cart's last catalog reprice has exceeded the time-to-live defined inCartOperationServiceProperties.getCartPricingTimeToLive()
.- Parameters:
cart
- theCart
to check against- Returns:
- true if the cart's last catalog reprice is stale, otherwise false
-
determineOldCartPrice
protected javax.money.MonetaryAmount determineOldCartPrice(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart) -
determineCartWithLatestPrices
@Nullable protected com.broadleafcommerce.cart.client.domain.Cart determineCartWithLatestPrices(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
latestPriceIsHigher
protected boolean latestPriceIsHigher(@NonNull @NonNull javax.money.MonetaryAmount latestCartPrice, @NonNull @NonNull javax.money.MonetaryAmount oldCartPrice) -
latestPriceIsLower
protected boolean latestPriceIsLower(@NonNull @NonNull javax.money.MonetaryAmount latestCartPrice, @NonNull @NonNull javax.money.MonetaryAmount oldCartPrice) -
getFailureMessage
protected String getFailureMessage(@NonNull @NonNull DefaultCheckoutFailureTypes checkoutFailureTypes) -
getPricingChangeMessage
protected String getPricingChangeMessage(@NonNull @NonNull javax.money.MonetaryAmount oldCartPrice, @NonNull @NonNull javax.money.MonetaryAmount latestCartPrice) -
createCartAlert
protected com.broadleafcommerce.cart.client.domain.CartAlert createCartAlert(@NonNull @NonNull String message) -
getMessageSource
protected org.springframework.context.MessageSource getMessageSource() -
getCartProvider
-
getCartOperationService
-
setCartOperationService
-
getProperties
-
getStaleCartPricingResultHolder
-
getCartPricingService
Deprecated.since 1.6, usegetCartOperationService()
instead. -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
setTypeFactory
@Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
getCartOperationServiceProperties
-
setCartOperationServiceProperties
@Autowired public void setCartOperationServiceProperties(CartOperationServiceProperties cartOperationServiceProperties)
-
getCartOperationService()
instead.