Class DefaultTransactionExecutionUtil
- All Implemented Interfaces:
TransactionExecutionUtil
-
Constructor Summary
ConstructorDescriptionDefaultTransactionExecutionUtil
(PaymentSummaryService paymentSummaryService, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionbuildTransactionExecutionDetail
(Payment payment, @NonNull PaymentTransaction transaction, com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) Builds aTransactionExecutionDetail
based on the providedTransactionExecutionRequest
andPaymentTransaction
.buildTransactionExecutionResponse
(@NonNull TransactionExecutionRequest request, @NonNull List<TransactionExecutionDetail> transactionExecutionDetails, Payment payment) buildTransactionExecutionResponse
(Payment payment, @NonNull PaymentTransaction transaction, com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) protected TransactionWithExecutableAmount
buildTransactionWithExecutableAmount
(PaymentTransaction parentTransaction, List<PaymentTransaction> transactions) Builds aTransactionWithExecutableAmount
based on the givenPaymentTransaction
.getParentTransactionWithExecutableAmounts
(@NonNull Payment payment, @NonNull TransactionExecutionRequest request) Gets a list ofTransactionWithExecutableAmounts
representing the parent transactions of the givenTransactionExecutionRequest
.protected PaymentSummaryService
protected javax.money.MonetaryAmount
getTransactionExecutableAmount
(@NonNull PaymentTransaction parentTransaction, @NonNull List<PaymentTransaction> transactions) Gets the executable amount for the givenPaymentTransaction
, which is thePaymentTransaction.getAmount()
- reversed amount from all the child reversing transactions.protected List<TransactionWithExecutableAmount>
getTransactionWithExecutableAmounts
(@NonNull Payment payment, @NonNull TransactionExecutionRequest request) Gathers a list ofTransactionWithExecutableAmount
objects based on the providedTransactionExecutionRequest
.protected List<TransactionWithExecutableAmount>
getTransactionWithExecutableAmountsByParentTransactionId
(@NonNull Payment payment, @NonNull TransactionExecutionRequest request) Gathers a single-item list ofTransactionWithExecutableAmount
objects based on the providedTransactionExecutionRequest.getParentTransactionId()
.protected com.broadleafcommerce.common.extension.TypeFactory
protected boolean
isReverseTransaction
(PaymentTransaction transaction, PaymentTransaction maybeReverseTransaction) Determines if the secondPaymentTransaction
is a reverse of the firstPaymentTransaction
.protected boolean
isSubsequentTransaction
(PaymentTransaction transaction, PaymentTransaction maybeSubsequentTransaction) Determines if the secondPaymentTransaction
is a subsequent of the firstPaymentTransaction
.protected boolean
isTransactionParentSourceEntity
(@NonNull PaymentTransaction transaction, @NonNull TransactionExecutionRequest request) Deprecated, for removal: This API element is subject to removal in a future version.this method is not used anymoreMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.paymenttransaction.service.utils.TransactionExecutionUtil
buildTransactionExecutionResponse, buildTransactionExecutionResponse
-
Constructor Details
-
DefaultTransactionExecutionUtil
public DefaultTransactionExecutionUtil(PaymentSummaryService paymentSummaryService, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
buildTransactionExecutionResponse
public TransactionExecutionResponse buildTransactionExecutionResponse(@NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull List<TransactionExecutionDetail> transactionExecutionDetails, @Nullable Payment payment) Description copied from interface:TransactionExecutionUtil
Builds aTransactionExecutionResponse
based on the givenTransactionExecutionDetails
andPayment
.This is used when multiple transactions were executed for a single
TransactionExecutionRequest
, which can happen when theTransactionExecutionRequest.getTransactionType()
requires one or more proceeding parent transactions to act against, such asDefaultTransactionTypes.REFUND
.For example, let's say we have 2 capture transactions, one for $10 and one for $5, and the
TransactionExecutionRequest
wants to execute a refund for $15. In this case, one refund transaction is needed for each parent capture transaction to cover the whole $15, one refund for $10 and one for $5.Note that out-of-box, the scenario of having multiple parent transactions is very unlikely and not expected, however it is supported.
- Specified by:
buildTransactionExecutionResponse
in interfaceTransactionExecutionUtil
- Parameters:
request
- theTransactionExecutionRequest
describing the desired details of the executiontransactionExecutionDetails
- a list ofTransactionExecutionDetails
that were executedpayment
- the relatedPayment
that the transactions acted against- Returns:
- a
TransactionExecutionResponse
based on the givenTransactionExecutionDetails
andPayment
-
buildTransactionExecutionDetail
public TransactionExecutionDetail buildTransactionExecutionDetail(@Nullable Payment payment, @NonNull @NonNull PaymentTransaction transaction, @Nullable com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) Description copied from interface:TransactionExecutionUtil
Builds aTransactionExecutionDetail
based on the providedTransactionExecutionRequest
andPaymentTransaction
.- Specified by:
buildTransactionExecutionDetail
in interfaceTransactionExecutionUtil
- Parameters:
payment
- The relatedPayment
that the transactions acted against.transaction
- The transaction that was executed.paymentResponse
- The payment gateway's response to the executed transaction- Returns:
- A
TransactionExecutionDetail
based on the providedTransactionExecutionRequest
andPaymentTransaction
-
buildTransactionExecutionResponse
public TransactionExecutionResponse buildTransactionExecutionResponse(@Nullable Payment payment, @NonNull @NonNull PaymentTransaction transaction, @Nullable com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) Description copied from interface:TransactionExecutionUtil
- Specified by:
buildTransactionExecutionResponse
in interfaceTransactionExecutionUtil
- Parameters:
payment
- The relatedPayment
that the request will act against.transaction
- The transaction that was executed.paymentResponse
- The payment gateway's response to the executed transaction- Returns:
- A
TransactionExecutionResponse
based on the providedPayment
, andPaymentTransaction
-
getParentTransactionWithExecutableAmounts
public List<TransactionWithExecutableAmount> getParentTransactionWithExecutableAmounts(@NonNull @NonNull Payment payment, @NonNull @NonNull TransactionExecutionRequest request) Description copied from interface:TransactionExecutionUtil
Gets a list ofTransactionWithExecutableAmounts
representing the parent transactions of the givenTransactionExecutionRequest
.This is used when the
TransactionExecutionRequest.getTransactionType()
requires one or more proceeding parent transactions to act against. For example, if the request is forDefaultTransactionTypes.REFUND
, this will retrieve all the non-fully-reversed parent transactions, such as capture, etc.Note that out-of-box, the scenario of having multiple parent transactions is very unlikely and not expected, however it is supported.
- Specified by:
getParentTransactionWithExecutableAmounts
in interfaceTransactionExecutionUtil
- Parameters:
payment
- thePayment
to look for the transaction from.- Returns:
- a list of
TransactionWithExecutableAmounts
representing the parent transactions of the givenTransactionExecutionRequest
-
getTransactionWithExecutableAmountsByParentTransactionId
protected List<TransactionWithExecutableAmount> getTransactionWithExecutableAmountsByParentTransactionId(@NonNull @NonNull Payment payment, @NonNull @NonNull TransactionExecutionRequest request) Gathers a single-item list ofTransactionWithExecutableAmount
objects based on the providedTransactionExecutionRequest.getParentTransactionId()
.- Parameters:
payment
- ThePayment
that owns the parent transaction.request
- ATransactionExecutionRequest
describing a transaction that is to be executed.- Returns:
- A single-item list of
TransactionWithExecutableAmount
objects based on the providedTransactionExecutionRequest.getParentTransactionId()
.
-
getTransactionWithExecutableAmounts
protected List<TransactionWithExecutableAmount> getTransactionWithExecutableAmounts(@NonNull @NonNull Payment payment, @NonNull @NonNull TransactionExecutionRequest request) Gathers a list ofTransactionWithExecutableAmount
objects based on the providedTransactionExecutionRequest
. If provided in the request, transactions will be identified byTransactionExecutionRequest.getParentSourceEntityType()
,TransactionExecutionRequest.getParentSourceEntityId()
, and transaction type. Otherwise, parent transactions will be identified by transaction type based on the providedTransactionExecutionRequest.getTransactionType()
.- Parameters:
payment
- ThePayment
that owns the parent transactions.request
- ATransactionExecutionRequest
describing a transaction that is to be executed.- Returns:
- A list of
TransactionWithExecutableAmount
objects based on the providedTransactionExecutionRequest
.
-
buildTransactionWithExecutableAmount
protected TransactionWithExecutableAmount buildTransactionWithExecutableAmount(PaymentTransaction parentTransaction, List<PaymentTransaction> transactions) Builds aTransactionWithExecutableAmount
based on the givenPaymentTransaction
.- Parameters:
parentTransaction
- thePaymentTransaction
to build theTransactionWithExecutableAmount
fortransactions
- a list of transactions that may contain the child reversing transactions of the given transaction- Returns:
- a
TransactionWithExecutableAmount
based on the givenPaymentTransaction
-
isTransactionParentSourceEntity
@Deprecated(since="1.0.6", forRemoval=true) protected boolean isTransactionParentSourceEntity(@NonNull @NonNull PaymentTransaction transaction, @NonNull @NonNull TransactionExecutionRequest request) Deprecated, for removal: This API element is subject to removal in a future version.this method is not used anymoreIf the givenTransactionExecutionRequest.getParentSourceEntityType()
andTransactionExecutionRequest.getParentSourceEntityId()
are provided, determines if the givenPaymentTransaction
is a parent transaction matching those properties. Returns true by default if not provided.- Parameters:
transaction
- thePaymentTransaction
to check againstrequest
- theTransactionExecutionRequest
to check with- Returns:
- whether the given
PaymentTransaction
is a parent transaction matching the givenrequest's parentSourceEntityType
andparentSourceEntityId
if provided. Returns true by default if not provided
-
getTransactionExecutableAmount
protected javax.money.MonetaryAmount getTransactionExecutableAmount(@NonNull @NonNull PaymentTransaction parentTransaction, @NonNull @NonNull List<PaymentTransaction> transactions) Gets the executable amount for the givenPaymentTransaction
, which is thePaymentTransaction.getAmount()
- reversed amount from all the child reversing transactions.For example, if the given transaction is an authorize transaction, it will find existing child reverse authorize transactions and calculates the actual executable amount. Note that any reverse authorize transactions that are not a child of this authorize transaction is not accounted.
- Parameters:
parentTransaction
- thePaymentTransaction
to calculate the executable amount fortransactions
- the other transactions that may contain the children transactions- Returns:
- the executable amount for the given
PaymentTransaction
-
isReverseTransaction
protected boolean isReverseTransaction(PaymentTransaction transaction, PaymentTransaction maybeReverseTransaction) Determines if the secondPaymentTransaction
is a reverse of the firstPaymentTransaction
.- Parameters:
transaction
- the transaction to check formaybeReverseTransaction
- the transaction to check if it's a reversing transaction for the first transaction- Returns:
- the second
PaymentTransaction
is a reverse of the firstPaymentTransaction
, otherwise false
-
isSubsequentTransaction
protected boolean isSubsequentTransaction(PaymentTransaction transaction, PaymentTransaction maybeSubsequentTransaction) Determines if the secondPaymentTransaction
is a subsequent of the firstPaymentTransaction
.- Parameters:
transaction
- the transaction to check formaybeSubsequentTransaction
- the transaction to check if it's a subsequent transaction for the first transaction- Returns:
- the second
PaymentTransaction
is a reverse of the firstPaymentTransaction
, otherwise false
-
getPaymentSummaryService
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-