Class DefaultTransactionExecutionUtil
- All Implemented Interfaces:
TransactionExecutionUtil
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultTransactionExecutionUtil(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 aTransactionExecutionDetailbased on the providedTransactionExecutionRequestandPaymentTransaction.buildTransactionExecutionResponse(@NonNull TransactionExecutionRequest request, @NonNull List<TransactionExecutionDetail> transactionExecutionDetails, Payment payment) buildTransactionExecutionResponse(Payment payment, @NonNull PaymentTransaction transaction, com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) protected TransactionWithExecutableAmountbuildTransactionWithExecutableAmount(PaymentTransaction parentTransaction, List<PaymentTransaction> transactions) Builds aTransactionWithExecutableAmountbased on the givenPaymentTransaction.getParentTransactionWithExecutableAmounts(@NonNull Payment payment, @NonNull TransactionExecutionRequest request) Gets a list ofTransactionWithExecutableAmountsrepresenting the parent transactions of the givenTransactionExecutionRequest.protected PaymentSummaryServiceprotected javax.money.MonetaryAmountgetTransactionExecutableAmount(@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 ofTransactionWithExecutableAmountobjects based on the providedTransactionExecutionRequest.protected List<TransactionWithExecutableAmount>getTransactionWithExecutableAmountsByParentTransactionId(@NonNull Payment payment, @NonNull TransactionExecutionRequest request) Gathers a single-item list ofTransactionWithExecutableAmountobjects based on the providedTransactionExecutionRequest.getParentTransactionId().protected com.broadleafcommerce.common.extension.TypeFactoryprotected booleanisReverseTransaction(PaymentTransaction transaction, PaymentTransaction maybeReverseTransaction) Determines if the secondPaymentTransactionis a reverse of the firstPaymentTransaction.protected booleanisSubsequentTransaction(PaymentTransaction transaction, PaymentTransaction maybeSubsequentTransaction) Determines if the secondPaymentTransactionis a subsequent of the firstPaymentTransaction.protected booleanisTransactionParentSourceEntity(@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, waitMethods 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:TransactionExecutionUtilBuilds aTransactionExecutionResponsebased on the givenTransactionExecutionDetailsandPayment.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
TransactionExecutionRequestwants 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:
buildTransactionExecutionResponsein interfaceTransactionExecutionUtil- Parameters:
request- theTransactionExecutionRequestdescribing the desired details of the executiontransactionExecutionDetails- a list ofTransactionExecutionDetailsthat were executedpayment- the relatedPaymentthat the transactions acted against- Returns:
- a
TransactionExecutionResponsebased on the givenTransactionExecutionDetailsandPayment
-
buildTransactionExecutionDetail
public TransactionExecutionDetail buildTransactionExecutionDetail(@Nullable Payment payment, @NonNull @NonNull PaymentTransaction transaction, @Nullable com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) Description copied from interface:TransactionExecutionUtilBuilds aTransactionExecutionDetailbased on the providedTransactionExecutionRequestandPaymentTransaction.- Specified by:
buildTransactionExecutionDetailin interfaceTransactionExecutionUtil- Parameters:
payment- The relatedPaymentthat the transactions acted against.transaction- The transaction that was executed.paymentResponse- The payment gateway's response to the executed transaction- Returns:
- A
TransactionExecutionDetailbased on the providedTransactionExecutionRequestandPaymentTransaction
-
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:
buildTransactionExecutionResponsein interfaceTransactionExecutionUtil- Parameters:
payment- The relatedPaymentthat the request will act against.transaction- The transaction that was executed.paymentResponse- The payment gateway's response to the executed transaction- Returns:
- A
TransactionExecutionResponsebased on the providedPayment, andPaymentTransaction
-
getParentTransactionWithExecutableAmounts
public List<TransactionWithExecutableAmount> getParentTransactionWithExecutableAmounts(@NonNull @NonNull Payment payment, @NonNull @NonNull TransactionExecutionRequest request) Description copied from interface:TransactionExecutionUtilGets a list ofTransactionWithExecutableAmountsrepresenting 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:
getParentTransactionWithExecutableAmountsin interfaceTransactionExecutionUtil- Parameters:
payment- thePaymentto look for the transaction from.- Returns:
- a list of
TransactionWithExecutableAmountsrepresenting the parent transactions of the givenTransactionExecutionRequest
-
getTransactionWithExecutableAmountsByParentTransactionId
protected List<TransactionWithExecutableAmount> getTransactionWithExecutableAmountsByParentTransactionId(@NonNull @NonNull Payment payment, @NonNull @NonNull TransactionExecutionRequest request) Gathers a single-item list ofTransactionWithExecutableAmountobjects based on the providedTransactionExecutionRequest.getParentTransactionId().- Parameters:
payment- ThePaymentthat owns the parent transaction.request- ATransactionExecutionRequestdescribing a transaction that is to be executed.- Returns:
- A single-item list of
TransactionWithExecutableAmountobjects based on the providedTransactionExecutionRequest.getParentTransactionId().
-
getTransactionWithExecutableAmounts
protected List<TransactionWithExecutableAmount> getTransactionWithExecutableAmounts(@NonNull @NonNull Payment payment, @NonNull @NonNull TransactionExecutionRequest request) Gathers a list ofTransactionWithExecutableAmountobjects 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- ThePaymentthat owns the parent transactions.request- ATransactionExecutionRequestdescribing a transaction that is to be executed.- Returns:
- A list of
TransactionWithExecutableAmountobjects based on the providedTransactionExecutionRequest.
-
buildTransactionWithExecutableAmount
protected TransactionWithExecutableAmount buildTransactionWithExecutableAmount(PaymentTransaction parentTransaction, List<PaymentTransaction> transactions) Builds aTransactionWithExecutableAmountbased on the givenPaymentTransaction.- Parameters:
parentTransaction- thePaymentTransactionto build theTransactionWithExecutableAmountfortransactions- a list of transactions that may contain the child reversing transactions of the given transaction- Returns:
- a
TransactionWithExecutableAmountbased 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 givenPaymentTransactionis a parent transaction matching those properties. Returns true by default if not provided.- Parameters:
transaction- thePaymentTransactionto check againstrequest- theTransactionExecutionRequestto check with- Returns:
- whether the given
PaymentTransactionis a parent transaction matching the givenrequest's parentSourceEntityTypeandparentSourceEntityIdif 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- thePaymentTransactionto 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 secondPaymentTransactionis 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
PaymentTransactionis a reverse of the firstPaymentTransaction, otherwise false
-
isSubsequentTransaction
protected boolean isSubsequentTransaction(PaymentTransaction transaction, PaymentTransaction maybeSubsequentTransaction) Determines if the secondPaymentTransactionis 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
PaymentTransactionis a reverse of the firstPaymentTransaction, otherwise false
-
getPaymentSummaryService
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-