Class FulfillmentCapturingPaymentListener


  • public class FulfillmentCapturingPaymentListener
    extends Object
    Listens to fulfillment capturing payment events and captures payment for them if necessary.
    • Method Detail

      • listen

        @StreamListener("orderOperationsFulfillmentCapturingPaymentInput")
        public void listen​(org.springframework.messaging.Message<FulfillmentStatusChangeEvent> message)
      • processEvent

        protected void processEvent​(@NonNull
                                    @NonNull org.springframework.messaging.Message<FulfillmentStatusChangeEvent> message)
      • attemptPaymentCapture

        protected void attemptPaymentCapture​(com.broadleafcommerce.order.client.domain.Order order,
                                             com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment,
                                             @Nullable
                                             com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • getOrder

        protected com.broadleafcommerce.order.client.domain.Order getOrder​(@NonNull
                                                                           @NonNull FulfillmentStatusChangeEvent event)
        Get the Order in the event, refreshing in case any payment changes have occurred on the order.
        Parameters:
        event - the event of the fulfillment being fulfilled
        Returns:
        the retrieved order based on the event
      • shouldCapturePayment

        protected boolean shouldCapturePayment​(com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment,
                                               com.broadleafcommerce.order.client.domain.Order order,
                                               com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Determine whether the OrderFulfillment should be captured. Extend this method to use some other criteria to capture payment.
        Parameters:
        fulfillment - The fulfillment to possibly capture payment for
        order - the order the fulfillment belongs to
        contextInfo - context information around sandbox and multitenant state
        Returns:
        whether the fulfillment should have payment captured
      • hasFulfillmentBeenCaptured

        protected boolean hasFulfillmentBeenCaptured​(com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment,
                                                     com.broadleafcommerce.order.client.domain.Order order,
                                                     com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Determines whether the OrderFulfillment has been captured by looking at PaymentSummaries related to this OrderFulfillment.
        Parameters:
        fulfillment - the OrderFulfillment to check against
        order - the Order that the OrderFulfillment belongs to
        contextInfo - context information around sandbox and multitenant state
        Returns:
        whether the OrderFulfillment has been captured
      • identifyAmountToCapture

        protected javax.money.MonetaryAmount identifyAmountToCapture​(com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment)
        Determines the total amount that should be captured for the fulfilled OrderFulfillment.
        Parameters:
        fulfillment - The fulfillment to be captured
        Returns:
        the amount of money to capture based on the fulfillment
      • changeFulfillmentStatus

        protected com.broadleafcommerce.order.client.domain.OrderFulfillment changeFulfillmentStatus​(@NonNull
                                                                                                     @NonNull PaymentCaptureAttemptResultStatus result,
                                                                                                     @NonNull
                                                                                                     @NonNull com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment,
                                                                                                     @Nullable
                                                                                                     com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • getNewStatusForPaymentCaptureResult

        protected com.broadleafcommerce.order.client.domain.OrderFulfillmentStatus getNewStatusForPaymentCaptureResult​(PaymentCaptureAttemptResultStatus result)
      • sendPaymentCaptureAttemptResult

        protected void sendPaymentCaptureAttemptResult​(@NonNull
                                                       @NonNull String result,
                                                       @NonNull
                                                       @NonNull com.broadleafcommerce.order.client.domain.Order order,
                                                       @NonNull
                                                       @NonNull com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment,
                                                       @Nullable
                                                       com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Produces & sends an event indicating that the order's payments were just successfully captured so that other systems/services can react accordingly.
        Parameters:
        result - the PaymentCaptureAttemptResultStatus of attempting the capture, indicating types of success or failure
        order - The most up-to-date order with partially or fully captured payments
        fulfillment - The fulfillment which had payment captured
        contextInfo - Context information around sandbox and multitenant state.
      • getTypeFactory

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

        protected OrderProvider<com.broadleafcommerce.order.client.domain.Order> getOrderProvider()
      • getIdempotentMessageService

        protected com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService getIdempotentMessageService()