Class CreatePaymentAccountEventListener
- java.lang.Object
 - 
- com.broadleafcommerce.customer.messaging.CreatePaymentAccountEventListener
 
 
- 
@DataRouteByKey("customer") public class CreatePaymentAccountEventListener extends ObjectAn 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 StringAPPLICATION_ID_PATHstatic StringCART_ID_PATHstatic StringCART_STATUS_PATHstatic StringCUSTOMER_CONTEXT_ID_PATHstatic StringCUSTOMER_ID_PATHprotected com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionServiceidempotentConsumptionServiceprotected com.fasterxml.jackson.databind.ObjectMapperobjectMapperprotected PaymentAccountService<PaymentAccount>paymentAccountServiceprotected PaymentProvider<Payment>paymentProviderprotected static StringSUBMITTEDprotected static StringSUCCESSstatic StringTENANT_ID_PATHprotected com.broadleafcommerce.common.extension.TypeFactorytypeFactory 
- 
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.ContextInfobuildContextInfo(@NonNull com.jayway.jsonpath.DocumentContext jsonContext)Builds aContextInfofor the application context id and tenant idprotected PaymentAccountbuildPaymentAccount(Payment payment)Builds aPaymentAccountbased on the provided cartPaymentprotected StringgetCardType(Payment payment)protected InstantgetDateRecorded(Payment payment)protected com.jayway.jsonpath.DocumentContextgetDocumentContext(@NonNull String payload)Parses the message payload into a `DocumentContext` which allows for JsonPath parsing using Jackson providers.protected IntegergetExpirationMonth(Payment payment)protected IntegergetExpirationYear(Payment payment)protected StringgetGatewayResponseCode(Payment payment)protected com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionServicegetIdempotentConsumptionService()protected StringgetLastFour(Payment payment)protected PaymentTransactiongetLatestSuccessfulTransaction(Payment payment)protected com.fasterxml.jackson.databind.ObjectMappergetObjectMapper()protected PaymentAccountService<PaymentAccount>getPaymentAccountService()protected PaymentProvider<Payment>getPaymentProvider()protected com.broadleafcommerce.common.extension.TypeFactorygetTypeFactory()protected booleanisSubmittedOrder(com.jayway.jsonpath.DocumentContext jsonContext)voidlisten(org.springframework.messaging.Message<String> message)Event listener entry point.protected voidprocessMessage(@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 aContextInfofor the application context id and tenant id- Parameters:
 jsonContext- The json representation of the message payload- Returns:
 - the 
ContextInfoof the completed checkout 
 
- 
buildPaymentAccount
protected PaymentAccount buildPaymentAccount(Payment payment)
Builds aPaymentAccountbased 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()
 
 - 
 
 -