Class 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)
    • 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, creates PaymentAccount(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 a ContextInfo 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 a PaymentAccount based on the provided cart Payment
        Parameters:
        payment - a cart payment that was used during checkout
        Returns:
        The populated PaymentAccount object
      • getCardType

        @Nullable
        protected String getCardType​(Payment payment)
      • getLastFour

        @Nullable
        protected String getLastFour​(Payment payment)
      • getExpirationMonth

        @Nullable
        protected Integer getExpirationMonth​(Payment payment)
      • getExpirationYear

        @Nullable
        protected Integer getExpirationYear​(Payment payment)
      • getDateRecorded

        protected Instant getDateRecorded​(Payment payment)
      • getGatewayResponseCode

        protected String getGatewayResponseCode​(Payment payment)
      • getIdempotentConsumptionService

        protected com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService getIdempotentConsumptionService()
      • getObjectMapper

        protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
      • getTypeFactory

        protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()