Class DefaultPaymentAuthReversalService
- All Implemented Interfaces:
PaymentAuthReversalService
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn intermediary data structure used internally byDefaultPaymentAuthReversalServiceto keep track of a reverse authorize that will be executed. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultPaymentAuthReversalService(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.PaymentReversalPackagefor thePaymentSummarythat has amount to reverse authorize.buildPaymentReversalPackages(com.broadleafcommerce.order.client.domain.Order order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) BuildsPaymentReversalPackagesfor 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 PaymentPriorityStrategyprotected PaymentProviderprotected com.broadleafcommerce.common.extension.TypeFactoryprotected voidprocessReversalPackage(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 TransactionExecutionResponsereverseAuthorizePayment(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.PaymentReversalPackageusinggetPaymentProvider().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 theOrderwhich are authorized but not captured.voidsetPaymentPriorityStrategy(PaymentPriorityStrategy paymentPriorityStrategy) protected booleanshouldSkipReversals(List<DefaultPaymentAuthReversalService.PaymentReversalPackage> reversePackages, com.broadleafcommerce.order.client.domain.Order order) Determines whether the reverse authorization process should be skipped.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:PaymentAuthReversalServiceExecutes reverse authorization(s) for all payments on theOrderwhich are authorized but not captured.- Specified by:
reverseRemainingAuthAmountsin interfacePaymentAuthReversalService- Parameters:
order- the order for which authorized payments should be reversedcontextInfo- context information surrounding multitenant state- Returns:
- the
TransactionExecutionResponsesfor 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) BuildsPaymentReversalPackagesfor all payments which have only been authorized, not captured.Only packages representing positive amounts (> $0.00) are constructed and returned; zero-dollar allocations are skipped.
- Parameters:
order- the order containing payments to reverse authorize- Returns:
- a list of all
PaymentReversalPackagesto 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 ofPaymentSummariesto 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 ofPaymentSummariesto sort based on reverse authorize priority- Returns:
- a new list representing the sorted result
-
buildPaymentReversalPackage
protected DefaultPaymentAuthReversalService.PaymentReversalPackage buildPaymentReversalPackage(PaymentSummary paymentSummary) Builds aDefaultPaymentAuthReversalService.PaymentReversalPackagefor thePaymentSummarythat has amount to reverse authorize.- Parameters:
paymentSummary- thePaymentSummaryto build aDefaultPaymentAuthReversalService.PaymentReversalPackagefor- Returns:
- a
DefaultPaymentAuthReversalService.PaymentReversalPackagefor thePaymentSummarythat 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
-
shouldSkipReversals
protected boolean shouldSkipReversals(List<DefaultPaymentAuthReversalService.PaymentReversalPackage> reversePackages, com.broadleafcommerce.order.client.domain.Order order) Determines whether the reverse authorization process should be skipped.Reversals are skipped if there are no reversal packages to process, or if the total sum of the reversal amounts across all packages is equal to zero. This prevents unnecessary locking of payments and avoids sending invalid zero-dollar reverse authorization transactions to downstream payment gateways.
- Parameters:
reversePackages- the list ofDefaultPaymentAuthReversalService.PaymentReversalPackages to evaluateorder- theOrderfor which this reversal operation is being performed- Returns:
trueif the reversal process should be skipped,falseotherwise
-
getPaymentIds
protected List<String> getPaymentIds(List<DefaultPaymentAuthReversalService.PaymentReversalPackage> reversalPackages) Gets a list of payment ids from the given list ofPaymentReversalPackages.- Parameters:
reversalPackages- a list ofPaymentReversalPackagesto 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.PaymentReversalPackageto processreverseResponses- the list ofTransactionExecutionResponsescontaining all the responsespaymentLockTokens- the list of payment lock tokensorder- theOrderfor 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.PaymentReversalPackageusinggetPaymentProvider().- Parameters:
reversePackage- theDefaultPaymentAuthReversalService.PaymentReversalPackageto execute the reverse authorize transaction forlockToken- the token that owns the payment lockorder- theOrderthat this reverse authorization is forcontextInfo- context information surrounding multitenant state- Returns:
- the
TransactionExecutionResponsefor the reverse authorize transaction.
-
getOrderProvider
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getPaymentProvider
-
getPaymentPriorityStrategy
-
setPaymentPriorityStrategy
-
sortPaymentsByPriority(List, ContextInfo)