Class DefaultPaymentCaptureService
- java.lang.Object
-
- com.broadleafcommerce.orderoperation.service.payment.DefaultPaymentCaptureService
-
- All Implemented Interfaces:
PaymentCaptureService
public class DefaultPaymentCaptureService extends Object implements PaymentCaptureService
-
-
Constructor Summary
Constructors Constructor Description DefaultPaymentCaptureService(PaymentProvider paymentProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected TransactionExecutionResponsecaptureAmount(@NonNull com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment, @NonNull PaymentSummary paymentSummary, @NonNull String lockToken, @NonNull javax.money.MonetaryAmount amountToCapture, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Captures the amount specified against the provided payment.List<TransactionExecutionResponse>captureFulfillment(@NonNull javax.money.MonetaryAmount totalToCapture, @NonNull com.broadleafcommerce.order.client.domain.Order order, @NonNull com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Responsible for capturing an amount from theOrder'spaymentsprotected javax.money.MonetaryAmountgetAmountAvailableForCapture(@NonNull PaymentSummary payment)Determines the amount that can be captured for this paymentprotected javax.money.MonetaryAmountgetAmountToCapture(@NonNull PaymentSummary payment, @NonNull javax.money.MonetaryAmount remainingToCapture)Based on the payment & the remaining to capture, return the amount that should be captured for this paymentprotected List<String>getPaymentIds(List<org.springframework.data.util.Pair<PaymentSummary,javax.money.MonetaryAmount>> amountToCapturePerPayment)Gets a list of payment ids from the given list of amounts to capture per payment.protected PaymentPriorityStrategygetPaymentPriorityStrategy()protected PaymentProvidergetPaymentProvider()protected List<PaymentSummary>getPaymentsWithAmountAvailableForCapture(@NonNull com.broadleafcommerce.order.client.domain.Order order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Identifies the order's payments that have some amount that is available to be captured.protected List<org.springframework.data.util.Pair<PaymentSummary,javax.money.MonetaryAmount>>identifyAmountToCapturePerPayment(@NonNull com.broadleafcommerce.order.client.domain.Order order, @NonNull javax.money.MonetaryAmount totalToCapture, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Determine how the total to capture should be distributed among the order's payments.voidsetPaymentPriorityStrategy(PaymentPriorityStrategy paymentPriorityStrategy)protected List<PaymentSummary>sortPaymentsByPriority(List<PaymentSummary> paymentSummaries)Deprecated.since 1.7.2, in favor ofsortPaymentsByPriority(List, ContextInfo)protected List<PaymentSummary>sortPaymentsByPriority(List<PaymentSummary> paymentSummaries, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Given a list ofPaymentSummaries, sorts them in order of which should be captured first.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.broadleafcommerce.orderoperation.service.payment.PaymentCaptureService
captureFulfillmentTotal
-
-
-
-
Constructor Detail
-
DefaultPaymentCaptureService
public DefaultPaymentCaptureService(PaymentProvider paymentProvider)
-
-
Method Detail
-
captureFulfillment
public List<TransactionExecutionResponse> captureFulfillment(@NonNull @NonNull javax.money.MonetaryAmount totalToCapture, @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)
Description copied from interface:PaymentCaptureServiceResponsible for capturing an amount from theOrder'spayments- Specified by:
captureFulfillmentin interfacePaymentCaptureService- Parameters:
totalToCapture- The amount to capture for theOrderFulfillmentorder- The order whose payments should be used to captured the specified amountfulfillment- The fulfillment to capture payment forcontextInfo- Context information around sandbox and multitenant state.- Returns:
- the
TransactionExecutionResponsesfor all the capture transactions
-
identifyAmountToCapturePerPayment
protected List<org.springframework.data.util.Pair<PaymentSummary,javax.money.MonetaryAmount>> identifyAmountToCapturePerPayment(@NonNull @NonNull com.broadleafcommerce.order.client.domain.Order order, @NonNull @NonNull javax.money.MonetaryAmount totalToCapture, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Determine how the total to capture should be distributed among the order's payments.- Parameters:
order- The order whose payments should be capturedtotalToCapture- The total that should be captured for the ordercontextInfo- Context information around sandbox and multitenant state.- Returns:
- a list of
Paircontainers holding an authorized payment and the amount that should be captured against that payment - Throws:
PaymentCaptureException- if the order's payments can't cover the requested total to capture
-
getPaymentsWithAmountAvailableForCapture
protected List<PaymentSummary> getPaymentsWithAmountAvailableForCapture(@NonNull @NonNull com.broadleafcommerce.order.client.domain.Order order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Identifies the order's payments that have some amount that is available to be captured.- Parameters:
order- The order whose payments should be capturedcontextInfo- Context information around sandbox and multitenant state.- Returns:
- The payment summaries that have some amount that is available to be captured
-
sortPaymentsByPriority
protected List<PaymentSummary> sortPaymentsByPriority(List<PaymentSummary> paymentSummaries, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Given a list ofPaymentSummaries, sorts them in order of which should be captured first.Any custom logic for capture payment priority should be added here.
- Parameters:
paymentSummaries- the list ofPaymentSummariesto sort based on capture prioritycontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- a new list representing the sorted result
-
sortPaymentsByPriority
@Deprecated protected List<PaymentSummary> sortPaymentsByPriority(List<PaymentSummary> paymentSummaries)
Deprecated.since 1.7.2, in favor ofsortPaymentsByPriority(List, ContextInfo)Given a list ofPaymentSummaries, sorts them in order of which should be captured first. By default, the same list is returned.Any custom logic for capture payment priority should be added here.
- Parameters:
paymentSummaries- the list ofPaymentSummariesto sort based on capture priority- Returns:
- a new list representing the sorted result
-
getAmountToCapture
protected javax.money.MonetaryAmount getAmountToCapture(@NonNull @NonNull PaymentSummary payment, @NonNull @NonNull javax.money.MonetaryAmount remainingToCapture)Based on the payment & the remaining to capture, return the amount that should be captured for this payment- Parameters:
payment- The authorized payment that we're considering for captureremainingToCapture- The remaining total for the order that should be captured- Returns:
- The amount that should be captured for this payment
-
getAmountAvailableForCapture
protected javax.money.MonetaryAmount getAmountAvailableForCapture(@NonNull @NonNull PaymentSummary payment)Determines the amount that can be captured for this payment- Parameters:
payment- The authorized payment that is a candidate for capture- Returns:
- The payment's amount that is available for capture
-
getPaymentIds
protected List<String> getPaymentIds(List<org.springframework.data.util.Pair<PaymentSummary,javax.money.MonetaryAmount>> amountToCapturePerPayment)
Gets a list of payment ids from the given list of amounts to capture per payment.- Parameters:
amountToCapturePerPayment- a list ofPaircontainers holding an authorized payment and the amount that should be captured against that payment- Returns:
- a list of payment ids
-
captureAmount
protected TransactionExecutionResponse captureAmount(@NonNull @NonNull com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment, @NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull String lockToken, @NonNull @NonNull javax.money.MonetaryAmount amountToCapture, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Captures the amount specified against the provided payment.If one of the
TransactionExecutionDetailsin theTransactionExecutionResponsefailed, aPaymentTransactionFailureExceptionis thrown.- Parameters:
fulfillment- The fulfillment to capture payment forpaymentSummary- The payment that is being capturedlockToken- the token that owns the payment lockamountToCapture- The amount that should be captured against the provided authorize transactioncontextInfo- Context information around sandbox and multitenant state.- Returns:
- The
TransactionExecutionResponseof the capture transaction - Throws:
PaymentTransactionFailureException- if one of the capture transactions fails
-
getPaymentProvider
protected PaymentProvider getPaymentProvider()
-
getPaymentPriorityStrategy
protected PaymentPriorityStrategy getPaymentPriorityStrategy()
-
setPaymentPriorityStrategy
@Autowired public void setPaymentPriorityStrategy(PaymentPriorityStrategy paymentPriorityStrategy)
-
-