Class NotificationCartPendingPaymentFailedListener
java.lang.Object
com.broadleafcommerce.notification.service.messaging.AbstractEmailNotificationMessageListener
com.broadleafcommerce.notification.service.messaging.NotificationCartPendingPaymentFailedListener
public class NotificationCartPendingPaymentFailedListener
extends AbstractEmailNotificationMessageListener
A message listener that triggers when a cart's previously pending payment failed. Responsible for
creating the cart pending payment failed notification.
- Author:
- Aastha B
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
protected static final String
protected static final String
protected static final String
protected static final String
Fields inherited from class com.broadleafcommerce.notification.service.messaging.AbstractEmailNotificationMessageListener
EMAIL_DELIVERY, messages, notificationService, tenantProvider, typeFactory, userResolver
-
Constructor Summary
ConstructorsConstructorDescriptionNotificationCartPendingPaymentFailedListener
(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentConsumptionService, NotificationService<Notification> notificationService, org.springframework.context.MessageSource messages, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CartPendingPaymentFailedPathProperties pathProperties, CartProvider cartProvider) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.broadleafcommerce.data.tracking.core.context.ContextInfo
buildNotificationContext
(@NonNull com.jayway.jsonpath.DocumentContext jsonContext) Build theContextInfo
for the current messageprotected CartProvider
protected String
Get the class name to identify this listener for handling message idempotency.protected String
Get the Json path to the full name from billing address fromCartPendingPaymentFailedPathProperties
.protected String
getCustomerName
(com.jayway.jsonpath.DocumentContext jsonContext) Read the customer name from the given context.protected String
protected String
getMessageType
(@NonNull com.jayway.jsonpath.DocumentContext jsonContext) Determine which message type should be sent.protected String
getNotificationSubject
(@NonNull com.jayway.jsonpath.DocumentContext jsonContext) Determine the subject to use for the email notification.protected CartPendingPaymentFailedPathProperties
getRecipients
(@NonNull com.jayway.jsonpath.DocumentContext jsonContext) Determine the recipients to use for the email notification.void
handleMessage
(org.springframework.messaging.Message<String> message) protected void
modifyNotification
(Notification notification, com.jayway.jsonpath.DocumentContext jsonContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Extension point to allow modifying the notification or context before sending to the notification serviceprotected void
populateCartItems
(com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
populateCartItemsAndGroups
(com.jayway.jsonpath.DocumentContext jsonContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
populateFulfillmentGroups
(com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected boolean
validateShouldSendNotification
(@NonNull com.jayway.jsonpath.DocumentContext jsonContext) Validate that the message state is valid to send the email.Methods inherited from class com.broadleafcommerce.notification.service.messaging.AbstractEmailNotificationMessageListener
buildNotification, buildNotification, getDocumentContext, getIdempotentConsumptionService, getMessages, getNotificationService, getObjectMapper, getPayload, getTenantProvider, getTypeFactory, getUserResolver, handleMessageInternal, modifyNotification, processMessage, resolveApplicationById, setTenantProvider, setUserResolver
-
Field Details
-
PENDING_PAYMENT_FAILED
- See Also:
-
SUBJECT_MESSAGE_PENDING_PAYMENT_FAILED
- See Also:
-
APPLICATION_ID_PATH
- See Also:
-
TENANT_ID_PATH
- See Also:
-
LOCALE
- See Also:
-
-
Constructor Details
-
NotificationCartPendingPaymentFailedListener
public NotificationCartPendingPaymentFailedListener(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentConsumptionService, NotificationService<Notification> notificationService, org.springframework.context.MessageSource messages, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CartPendingPaymentFailedPathProperties pathProperties, CartProvider cartProvider)
-
-
Method Details
-
handleMessage
@StreamListener("cartPendingPaymentFailedNotification") public void handleMessage(org.springframework.messaging.Message<String> message) -
getClassName
Get the class name to identify this listener for handling message idempotency.- Specified by:
getClassName
in classAbstractEmailNotificationMessageListener
- Returns:
- the listener's class name
-
validateShouldSendNotification
protected boolean validateShouldSendNotification(@NonNull @NonNull com.jayway.jsonpath.DocumentContext jsonContext) Validate that the message state is valid to send the email.- Specified by:
validateShouldSendNotification
in classAbstractEmailNotificationMessageListener
- Parameters:
jsonContext
- the message payload- Returns:
- whether the email should be sent
-
getMessageType
Determine which message type should be sent.- Specified by:
getMessageType
in classAbstractEmailNotificationMessageListener
- Parameters:
jsonContext
- the message payload- Returns:
- the message type to send
-
getNotificationSubject
protected String getNotificationSubject(@NonNull @NonNull com.jayway.jsonpath.DocumentContext jsonContext) Determine the subject to use for the email notification.- Specified by:
getNotificationSubject
in classAbstractEmailNotificationMessageListener
- Parameters:
jsonContext
- the message payload- Returns:
- the subject to use for the email notification
-
getRecipients
protected List<Recipient> getRecipients(@NonNull @NonNull com.jayway.jsonpath.DocumentContext jsonContext) Determine the recipients to use for the email notification.- Specified by:
getRecipients
in classAbstractEmailNotificationMessageListener
- Parameters:
jsonContext
- the message payload- Returns:
- the recipients to use for the email notification
-
getCustomerName
Read the customer name from the given context.
If the customer is registered, the full name from#getRequesterNamePath()
will be returned. Otherwise, it returns the customer name from the billing address.This method will check the deprecated name path if the configured path does not exist in the given context.
- Parameters:
jsonContext
- the message payload.- Returns:
- The name of the customer from the given payload.
-
getCustomerEmailPath
Get the Json path to the full name from billing address fromCartPendingPaymentFailedPathProperties
.- Returns:
- The Json path to the full name from billing address property
-
getCustomerNamePath
-
buildNotificationContext
protected com.broadleafcommerce.data.tracking.core.context.ContextInfo buildNotificationContext(@NonNull @NonNull com.jayway.jsonpath.DocumentContext jsonContext) Build theContextInfo
for the current message- Specified by:
buildNotificationContext
in classAbstractEmailNotificationMessageListener
- Parameters:
jsonContext
- the payload of the message- Returns:
- the NotificationContext for the current message
-
modifyNotification
protected void modifyNotification(Notification notification, com.jayway.jsonpath.DocumentContext jsonContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from class:AbstractEmailNotificationMessageListener
Extension point to allow modifying the notification or context before sending to the notification service- Overrides:
modifyNotification
in classAbstractEmailNotificationMessageListener
- Parameters:
notification
- the Notification for the current messagejsonContext
- the message payloadcontext
- The context of the request
-
populateCartItemsAndGroups
protected void populateCartItemsAndGroups(com.jayway.jsonpath.DocumentContext jsonContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
populateCartItems
protected void populateCartItems(com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
populateFulfillmentGroups
protected void populateFulfillmentGroups(com.broadleafcommerce.cart.client.domain.CheckoutCart checkoutCart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getPathProperties
-
getCartProvider
-