Class FulfillmentCapturingPaymentListener
- java.lang.Object
-
- com.broadleafcommerce.orderoperation.service.messaging.fulfillments.FulfillmentCapturingPaymentListener
-
public class FulfillmentCapturingPaymentListener extends Object
Listens to fulfillment capturing payment events and captures payment for them if necessary.
-
-
Constructor Summary
Constructors Constructor Description FulfillmentCapturingPaymentListener(com.broadleafcommerce.common.extension.TypeFactory typeFactory, OrderProvider<com.broadleafcommerce.order.client.domain.Order> orderProvider, PaymentCaptureService paymentCaptureService, PaymentCaptureAttemptedProducer paymentCaptureCompletionProducer, FulfillmentOperationService fulfillmentOperationService, com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentMessageService, ResourceLockProvider resourceLockProvider, PaymentProvider paymentProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
attemptPaymentCapture(com.broadleafcommerce.order.client.domain.Order order, com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected com.broadleafcommerce.order.client.domain.OrderFulfillment
changeFulfillmentStatus(@NonNull PaymentCaptureAttemptResultStatus result, @NonNull com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected FulfillmentOperationService
getFulfillmentOperationService()
protected com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService
getIdempotentMessageService()
protected com.broadleafcommerce.order.client.domain.OrderFulfillmentStatus
getNewStatusForPaymentCaptureResult(PaymentCaptureAttemptResultStatus result)
protected com.broadleafcommerce.order.client.domain.Order
getOrder(@NonNull FulfillmentStatusChangeEvent event)
Get theOrder
in theevent
, refreshing in case any payment changes have occurred on the order.protected OrderProvider<com.broadleafcommerce.order.client.domain.Order>
getOrderProvider()
protected PaymentCaptureAttemptedProducer
getPaymentCaptureCompletionProducer()
protected PaymentCaptureService
getPaymentCaptureService()
protected PaymentProvider
getPaymentProvider()
protected ResourceLockProvider
getResourceLockProvider()
protected com.broadleafcommerce.common.extension.TypeFactory
getTypeFactory()
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 theOrderFulfillment
has been captured by looking atPaymentSummaries
related to thisOrderFulfillment
.protected javax.money.MonetaryAmount
identifyAmountToCapture(com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment)
Determines the total amount that should be captured for the fulfilledOrderFulfillment
.void
listen(org.springframework.messaging.Message<FulfillmentStatusChangeEvent> message)
protected void
processEvent(@NonNull org.springframework.messaging.Message<FulfillmentStatusChangeEvent> message)
protected void
sendPaymentCaptureAttemptResult(@NonNull String result, @NonNull com.broadleafcommerce.order.client.domain.Order order, @NonNull com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment, 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.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 theOrderFulfillment
should be captured.
-
-
-
Constructor Detail
-
FulfillmentCapturingPaymentListener
public FulfillmentCapturingPaymentListener(com.broadleafcommerce.common.extension.TypeFactory typeFactory, OrderProvider<com.broadleafcommerce.order.client.domain.Order> orderProvider, PaymentCaptureService paymentCaptureService, PaymentCaptureAttemptedProducer paymentCaptureCompletionProducer, FulfillmentOperationService fulfillmentOperationService, com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentMessageService, ResourceLockProvider resourceLockProvider, PaymentProvider paymentProvider)
-
-
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 theOrder
in theevent
, 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 theOrderFulfillment
should be captured. Extend this method to use some other criteria to capture payment.- Parameters:
fulfillment
- The fulfillment to possibly capture payment fororder
- the order the fulfillment belongs tocontextInfo
- 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 theOrderFulfillment
has been captured by looking atPaymentSummaries
related to thisOrderFulfillment
.- Parameters:
fulfillment
- theOrderFulfillment
to check againstorder
- theOrder
that theOrderFulfillment
belongs tocontextInfo
- 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 fulfilledOrderFulfillment
.- 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
- thePaymentCaptureAttemptResultStatus
of attempting the capture, indicating types of success or failureorder
- The most up-to-date order with partially or fully captured paymentsfulfillment
- The fulfillment which had payment capturedcontextInfo
- 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()
-
getPaymentCaptureService
protected PaymentCaptureService getPaymentCaptureService()
-
getPaymentCaptureCompletionProducer
protected PaymentCaptureAttemptedProducer getPaymentCaptureCompletionProducer()
-
getFulfillmentOperationService
protected FulfillmentOperationService getFulfillmentOperationService()
-
getIdempotentMessageService
protected com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService getIdempotentMessageService()
-
getResourceLockProvider
protected ResourceLockProvider getResourceLockProvider()
-
getPaymentProvider
protected PaymentProvider getPaymentProvider()
-
-