Class DefaultPaymentAuthReversalService
java.lang.Object
com.broadleafcommerce.orderoperation.service.payment.DefaultPaymentAuthReversalService
- All Implemented Interfaces:
PaymentAuthReversalService
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An intermediary data structure used internally byDefaultPaymentAuthReversalService
to keep track of a reverse authorize that will be executed. -
Constructor Summary
ConstructorDescriptionDefaultPaymentAuthReversalService
(OrderProvider<com.broadleafcommerce.order.client.domain.Order> orderProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory, PaymentProvider paymentProvider) -
Method Summary
Modifier and TypeMethodDescriptionbuildPaymentReversalPackage
(PaymentSummary paymentSummary) Builds aDefaultPaymentAuthReversalService.PaymentReversalPackage
for thePaymentSummary
that has amount to reverse authorize.buildPaymentReversalPackages
(com.broadleafcommerce.order.client.domain.Order order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) BuildsPaymentReversalPackages
for all payments which have only been authorized, not captured.protected OrderProvider<com.broadleafcommerce.order.client.domain.Order>
getPaymentIds
(List<DefaultPaymentAuthReversalService.PaymentReversalPackage> reversalPackages) Gets a list of payment ids from the given list ofPaymentReversalPackages
.protected PaymentPriorityStrategy
protected PaymentProvider
protected com.broadleafcommerce.common.extension.TypeFactory
protected void
processReversalPackage
(DefaultPaymentAuthReversalService.PaymentReversalPackage reversePackage, List<TransactionExecutionResponse> reverseResponses, Map<String, String> paymentLockTokens, com.broadleafcommerce.order.client.domain.Order order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Processes the givenDefaultPaymentAuthReversalService.PaymentReversalPackage
.protected TransactionExecutionResponse
reverseAuthorizePayment
(DefaultPaymentAuthReversalService.PaymentReversalPackage reversePackage, @NonNull String lockToken, com.broadleafcommerce.order.client.domain.Order order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Executes the reverse authorize transaction for the givenDefaultPaymentAuthReversalService.PaymentReversalPackage
usinggetPaymentProvider()
.protected List<TransactionExecutionResponse>
reverseAuthorizePayments
(List<DefaultPaymentAuthReversalService.PaymentReversalPackage> reversePackages, com.broadleafcommerce.order.client.domain.Order order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given a list ofPaymentReversalPackages
, executes the reverse authorize transactions usinggetPaymentProvider()
.reverseRemainingAuthAmounts
(com.broadleafcommerce.order.client.domain.Order order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Executes reverse authorization(s) for all payments on theOrder
which are authorized but not captured.void
setPaymentPriorityStrategy
(PaymentPriorityStrategy paymentPriorityStrategy) protected List<PaymentSummary>
sortPaymentsByPriority
(List<PaymentSummary> paymentSummaries) Deprecated.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 reverse authorized first.
-
Constructor Details
-
DefaultPaymentAuthReversalService
public DefaultPaymentAuthReversalService(OrderProvider<com.broadleafcommerce.order.client.domain.Order> orderProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory, PaymentProvider paymentProvider)
-
-
Method Details
-
reverseRemainingAuthAmounts
public List<TransactionExecutionResponse> reverseRemainingAuthAmounts(com.broadleafcommerce.order.client.domain.Order order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PaymentAuthReversalService
Executes reverse authorization(s) for all payments on theOrder
which are authorized but not captured.- Specified by:
reverseRemainingAuthAmounts
in interfacePaymentAuthReversalService
- Parameters:
order
- the order for which authorized payments should be reversedcontextInfo
- context information surrounding multitenant state- Returns:
- the
TransactionExecutionResponses
for all the reverse authorize transactions
-
buildPaymentReversalPackages
protected List<DefaultPaymentAuthReversalService.PaymentReversalPackage> buildPaymentReversalPackages(com.broadleafcommerce.order.client.domain.Order order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) BuildsPaymentReversalPackages
for all payments which have only been authorized, not captured.- Parameters:
order
- the order containing payments to reverse authorize- Returns:
- a list of all
PaymentReversalPackages
to reverse authorize all order payments which have only been authorized, not 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 reverse authorized first.By default, the payments are returned as-is. Reverse authorize transactions are typically executed against an entire order for the remaining authorized amount, so the priorities don't necessarily matter.
Any custom logic for reverse authorize payment priority should be added here.
- Parameters:
paymentSummaries
- the list ofPaymentSummaries
to sort based on reverse authorize 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 reverse authorized first. By default, the same list is returned.Any custom logic for reverse authorize payment priority should be added here.
- Parameters:
paymentSummaries
- the list ofPaymentSummaries
to sort based on reverse authorize priority- Returns:
- a new list representing the sorted result
-
buildPaymentReversalPackage
protected DefaultPaymentAuthReversalService.PaymentReversalPackage buildPaymentReversalPackage(PaymentSummary paymentSummary) Builds aDefaultPaymentAuthReversalService.PaymentReversalPackage
for thePaymentSummary
that has amount to reverse authorize.- Parameters:
paymentSummary
- thePaymentSummary
to build aDefaultPaymentAuthReversalService.PaymentReversalPackage
for- Returns:
- a
DefaultPaymentAuthReversalService.PaymentReversalPackage
for thePaymentSummary
that has amount to reverse authorize
-
reverseAuthorizePayments
protected List<TransactionExecutionResponse> reverseAuthorizePayments(List<DefaultPaymentAuthReversalService.PaymentReversalPackage> reversePackages, com.broadleafcommerce.order.client.domain.Order order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given a list ofPaymentReversalPackages
, executes the reverse authorize transactions usinggetPaymentProvider()
.Returns the responses for each reverse authorize transaction.
- Parameters:
reversePackages
- a list of payment reverse packages whose reversal transactions need to be executedorder
- the order to reverse authorize the payments forcontextInfo
- context information surrounding multitenant state- Returns:
- the reverse authorize execution responses after executing all reverse authorizations
- Throws:
PaymentTransactionFailureException
- if any of the transactions were not successfully executed
-
getPaymentIds
protected List<String> getPaymentIds(List<DefaultPaymentAuthReversalService.PaymentReversalPackage> reversalPackages) Gets a list of payment ids from the given list ofPaymentReversalPackages
.- Parameters:
reversalPackages
- a list ofPaymentReversalPackages
to get the payment ids from- Returns:
- a list of payment ids
-
processReversalPackage
protected void processReversalPackage(DefaultPaymentAuthReversalService.PaymentReversalPackage reversePackage, List<TransactionExecutionResponse> reverseResponses, Map<String, String> paymentLockTokens, com.broadleafcommerce.order.client.domain.Order order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Processes the givenDefaultPaymentAuthReversalService.PaymentReversalPackage
.- Parameters:
reversePackage
- theDefaultPaymentAuthReversalService.PaymentReversalPackage
to processreverseResponses
- the list ofTransactionExecutionResponses
containing all the responsespaymentLockTokens
- the list of payment lock tokensorder
- theOrder
for this payment reversalcontextInfo
- context information surrounding multitenant state
-
reverseAuthorizePayment
protected TransactionExecutionResponse reverseAuthorizePayment(DefaultPaymentAuthReversalService.PaymentReversalPackage reversePackage, @NonNull @NonNull String lockToken, com.broadleafcommerce.order.client.domain.Order order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Executes the reverse authorize transaction for the givenDefaultPaymentAuthReversalService.PaymentReversalPackage
usinggetPaymentProvider()
.- Parameters:
reversePackage
- theDefaultPaymentAuthReversalService.PaymentReversalPackage
to execute the reverse authorize transaction forlockToken
- the token that owns the payment lockorder
- theOrder
that this reverse authorization is forcontextInfo
- context information surrounding multitenant state- Returns:
- the
TransactionExecutionResponse
for the reverse authorize transaction.
-
getOrderProvider
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getPaymentProvider
-
getPaymentPriorityStrategy
-
setPaymentPriorityStrategy
-
sortPaymentsByPriority(List, ContextInfo)