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 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>captureFulfillmentTotal(@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 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.protected List<PaymentSummary>sortPaymentsByPriority(List<PaymentSummary> paymentSummaries)Given a list ofPaymentSummaries, sorts them in order of which should be captured first. 
 - 
 
- 
- 
Constructor Detail
- 
DefaultPaymentCaptureService
public DefaultPaymentCaptureService(PaymentProvider paymentProvider)
 
 - 
 
- 
Method Detail
- 
captureFulfillmentTotal
public List<TransactionExecutionResponse> captureFulfillmentTotal(@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:
 captureFulfillmentTotalin interfacePaymentCaptureService- Parameters:
 order- 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 order- 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 captured- Returns:
 - The payment summaries that have some amount that is available to be captured
 
 
- 
sortPaymentsByPriority
protected List<PaymentSummary> sortPaymentsByPriority(List<PaymentSummary> paymentSummaries)
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.- 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 the capture transaction fails
 
- 
getPaymentProvider
protected PaymentProvider getPaymentProvider()
 
 - 
 
 -