Class CreatePaymentAccountEventListener
- java.lang.Object
-
- com.broadleafcommerce.customer.messaging.CreatePaymentAccountEventListener
-
@DataRouteByKey("customer") public class CreatePaymentAccountEventListener extends Object
An event listener that triggers when an order is successfully submitted. Responsible for checking the completed cart for any newly specified payment methods that the user wishes to save for future usage or usage of any previously saved payment methods to record the latest results.- Author:
- Chris Kittrell (ckittrell)
-
-
Field Summary
Fields Modifier and Type Field Description static String
APPLICATION_ID_PATH
static String
CART_ID_PATH
static String
CART_STATUS_PATH
static String
CUSTOMER_CONTEXT_ID_PATH
static String
CUSTOMER_ID_PATH
protected com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService
idempotentConsumptionService
protected com.fasterxml.jackson.databind.ObjectMapper
objectMapper
protected PaymentAccountService<PaymentAccount>
paymentAccountService
protected PaymentProvider<Payment>
paymentProvider
protected static String
SUBMITTED
protected static String
SUCCESS
static String
TENANT_ID_PATH
protected com.broadleafcommerce.common.extension.TypeFactory
typeFactory
-
Constructor Summary
Constructors Constructor Description CreatePaymentAccountEventListener(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentConsumptionService, PaymentAccountService<PaymentAccount> paymentAccountService, PaymentProvider<Payment> paymentProvider, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.broadleafcommerce.data.tracking.core.context.ContextInfo
buildContextInfo(@NonNull com.jayway.jsonpath.DocumentContext jsonContext)
Builds aContextInfo
for the application context id and tenant idprotected PaymentAccount
buildPaymentAccount(Payment payment)
Builds aPaymentAccount
based on the provided cartPayment
protected String
getCardType(Payment payment)
protected Instant
getDateRecorded(Payment payment)
protected com.jayway.jsonpath.DocumentContext
getDocumentContext(@NonNull String payload)
Parses the message payload into a `DocumentContext` which allows for JsonPath parsing using Jackson providers.protected Integer
getExpirationMonth(Payment payment)
protected Integer
getExpirationYear(Payment payment)
protected String
getGatewayResponseCode(Payment payment)
protected com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService
getIdempotentConsumptionService()
protected String
getLastFour(Payment payment)
protected PaymentTransaction
getLatestSuccessfulTransaction(Payment payment)
protected com.fasterxml.jackson.databind.ObjectMapper
getObjectMapper()
protected PaymentAccountService<PaymentAccount>
getPaymentAccountService()
protected PaymentProvider<Payment>
getPaymentProvider()
protected com.broadleafcommerce.common.extension.TypeFactory
getTypeFactory()
protected boolean
isSubmittedOrder(com.jayway.jsonpath.DocumentContext jsonContext)
void
listen(org.springframework.messaging.Message<String> message)
Event listener entry point.protected void
processMessage(@NonNull org.springframework.messaging.Message<String> message)
Handles the interpretation of the message payload & if necessary, createsPaymentAccount(s)
for the customer
-
-
-
Field Detail
-
SUBMITTED
protected static final String SUBMITTED
- See Also:
- Constant Field Values
-
SUCCESS
protected static final String SUCCESS
- See Also:
- Constant Field Values
-
CART_STATUS_PATH
public static final String CART_STATUS_PATH
- See Also:
- Constant Field Values
-
CART_ID_PATH
public static final String CART_ID_PATH
- See Also:
- Constant Field Values
-
APPLICATION_ID_PATH
public static final String APPLICATION_ID_PATH
- See Also:
- Constant Field Values
-
TENANT_ID_PATH
public static final String TENANT_ID_PATH
- See Also:
- Constant Field Values
-
CUSTOMER_CONTEXT_ID_PATH
public static final String CUSTOMER_CONTEXT_ID_PATH
- See Also:
- Constant Field Values
-
CUSTOMER_ID_PATH
public static final String CUSTOMER_ID_PATH
- See Also:
- Constant Field Values
-
idempotentConsumptionService
protected final com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentConsumptionService
-
paymentAccountService
protected final PaymentAccountService<PaymentAccount> paymentAccountService
-
paymentProvider
protected final PaymentProvider<Payment> paymentProvider
-
objectMapper
protected final com.fasterxml.jackson.databind.ObjectMapper objectMapper
-
typeFactory
protected final com.broadleafcommerce.common.extension.TypeFactory typeFactory
-
-
Constructor Detail
-
CreatePaymentAccountEventListener
public CreatePaymentAccountEventListener(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentConsumptionService, PaymentAccountService<PaymentAccount> paymentAccountService, PaymentProvider<Payment> paymentProvider, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Detail
-
listen
@StreamListener("checkoutCompletionInputCustomer") public void listen(org.springframework.messaging.Message<String> message)
Event listener entry point. Checks if the message has already been received and, if not, begins processing it.- Parameters:
message
- the message to be processed
-
processMessage
protected void processMessage(@NonNull @NonNull org.springframework.messaging.Message<String> message)
Handles the interpretation of the message payload & if necessary, createsPaymentAccount(s)
for the customer- Parameters:
message
- the message to be processed
-
getDocumentContext
protected com.jayway.jsonpath.DocumentContext getDocumentContext(@NonNull @NonNull String payload)
Parses the message payload into a `DocumentContext` which allows for JsonPath parsing using Jackson providers.- Parameters:
payload
- the message payload- Returns:
- a `DocumentContext` representation of the message payload
-
isSubmittedOrder
protected boolean isSubmittedOrder(com.jayway.jsonpath.DocumentContext jsonContext)
-
buildContextInfo
protected com.broadleafcommerce.data.tracking.core.context.ContextInfo buildContextInfo(@NonNull @NonNull com.jayway.jsonpath.DocumentContext jsonContext)
Builds aContextInfo
for the application context id and tenant id- Parameters:
jsonContext
- The json representation of the message payload- Returns:
- the
ContextInfo
of the completed checkout
-
buildPaymentAccount
protected PaymentAccount buildPaymentAccount(Payment payment)
Builds aPaymentAccount
based on the provided cartPayment
- Parameters:
payment
- a cart payment that was used during checkout- Returns:
- The populated PaymentAccount object
-
getLatestSuccessfulTransaction
protected PaymentTransaction getLatestSuccessfulTransaction(Payment payment)
-
getIdempotentConsumptionService
protected com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService getIdempotentConsumptionService()
-
getPaymentAccountService
protected PaymentAccountService<PaymentAccount> getPaymentAccountService()
-
getPaymentProvider
protected PaymentProvider<Payment> getPaymentProvider()
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-
-