Class DefaultTransactionExecutionService
- All Implemented Interfaces:
TransactionExecutionService
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An intermediary data structure used internally byTransactionExecutionService
to hold all the relevant data to execute a transaction against aparent transaction
. -
Constructor Summary
ConstructorDescriptionDefaultTransactionExecutionService
(PaymentService<Payment> paymentService, PaymentManagementService<Payment> paymentManagementService, TransactionExecutionRequestValidator requestValidator, PaymentLockService<Payment> paymentLockService, PaymentRequestService paymentRequestService, com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider paymentGatewayResourceProvider, PaymentTransactionService<PaymentTransaction> paymentTransactionService, TransactionResponseService transactionResponseService, TransactionExecutionUtil transactionExecutionUtil, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionauthorize
(@NonNull TransactionExecutionRequest request, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Communicates with the relevant payment gateway to execute anDefaultTransactionTypes.AUTHORIZE
transaction.authorizeAndCapture
(@NonNull TransactionExecutionRequest request, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Communicates with the relevant payment gateway to execute anDefaultTransactionTypes.AUTHORIZE_AND_CAPTURE
transaction.buildAdditionalPaymentProperties
(Payment payment) Hookpoint for populating information from the payment to identify a parent transaction for the gateway.protected com.broadleafcommerce.paymentgateway.domain.GatewayTransactionResponse
buildGatewayTransactionResponse
(@NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.enums.TransactionType transactionType, @NonNull Map<String, Object> transactionResults, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Builds aGatewayTransactionResponse
from the payment and including the gateway transaction results.protected PaymentRef
buildPaymentRef
(Payment payment) protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse
buildPaymentResponseFromTransactionResults
(@NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.GatewayTransactionResponse gatewayTransactionResponse, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Builds aPaymentResponse
from the gateway transaction results.protected javax.money.MonetaryAmount
calculateProratedAmount
(javax.money.MonetaryAmount requestDetailTotal, javax.money.MonetaryAmount transactionAmount, javax.money.MonetaryAmount requestTransactionAmount) capture
(@NonNull TransactionExecutionRequest request, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Communicates with the relevant payment gateway to execute aDefaultTransactionTypes.CAPTURE
transaction.protected PaymentTransaction
createPaymentTransaction
(@NonNull TransactionAmountDetails transactionAmountDetails, @NonNull TransactionExecutionRequest request, @NonNull Payment payment, PaymentTransaction parentTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransaction
createPaymentTransaction
(@NonNull TransactionExecutionRequest request, @NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransaction
createPaymentTransaction
(@NonNull TransactionExecutionRequest request, @NonNull Payment payment, PaymentTransaction parentTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransaction
createPaymentTransaction
(@NonNull javax.money.MonetaryAmount transactionAmount, @NonNull TransactionExecutionRequest request, @NonNull Payment payment, PaymentTransaction parentTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
createSavedPaymentMethodIfNeeded
(@NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Creates a saved payment method via the registered implementation ofSavedPaymentMethodManagementService
from the givenPayment
if necessary.detachedCredit
(@NonNull TransactionExecutionRequest request, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Communicates with the relevant payment gateway to execute aDefaultTransactionTypes.DETACHED_CREDIT
transaction.protected String
determineTransactionStatus
(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Determines the new status of thePaymentTransaction
based on the contents of thePaymentResponse
protected org.apache.commons.lang3.tuple.Pair<Payment,
TransactionExecutionDetail> executeAgainstParentTransaction
(@NonNull Payment payment, @NonNull DefaultTransactionExecutionService.ParentTransactionExecutionPackage executionPackage, String lockToken) Executes the givenDefaultTransactionExecutionService.ParentTransactionExecutionPackage
.protected TransactionExecutionResponse
executeAgainstParentTransactions
(@NonNull TransactionExecutionRequest request, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds and executes the givenTransactionExecutionRequest
against parent transactions.protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse
executePaymentRequest
(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest, @NonNull com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService transactionService, @NonNull TransactionExecutionRequest executionRequest) Deprecated, for removal: This API element is subject to removal in a future version.protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse
executePaymentRequest
(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest, @NonNull com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService transactionService, @NonNull TransactionExecutionRequest executionRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected TransactionWithExecutableAmount
findFirstExecutableParentTransaction
(List<TransactionWithExecutableAmount> parentTransactions, String paymentId) Finds the firstTransactionWithExecutableAmount
with amount available to execute.protected String
getApplicationIdFromContext
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentCustomerNotificationService
protected Optional<PaymentTransaction>
getExisting3DSTransactionResult
(@NonNull Payment payment, @NonNull PaymentTransaction parentTransaction) protected MonetaryAmountRoundingHelper
getParentTransactionExecutionPackages
(TransactionExecutionRequest request, List<TransactionWithExecutableAmount> parentTransactions, javax.money.MonetaryAmount totalToExecute, Payment payment, com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService transactionService, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets a list ofParentTransactionExecutionPackages
based on the given parameters.protected com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider
protected PaymentLockService<Payment>
protected PaymentManagementService<Payment>
protected PaymentRequestService
protected PaymentService<Payment>
protected PaymentTransaction
getPaymentTransactionById
(@NonNull Payment payment, @NonNull String parentTransactionId) protected PaymentTransactionService<PaymentTransaction>
protected TransactionExecutionRequestValidator
protected SavedPaymentMethodManagementService
protected SavedPaymentMethodService<SavedPaymentMethod>
protected String
getTenantIdFromContext
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Function<com.broadleafcommerce.paymentgateway.domain.PaymentRequest,
com.broadleafcommerce.paymentgateway.domain.PaymentResponse> getTransactionExecutionFunction
(@NonNull TransactionExecutionRequest request, com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService transactionService) Gets a transaction executionFunction
based on the givenTransactionExecutionRequest.getTransactionType()
and the givenPaymentGatewayTransactionService
.protected Optional<TransactionExecutionResponse>
getTransactionExecutionResponse
(@NonNull TransactionExecutionRequest request, @NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns the transaction execution response, if the payment has the 3DS transaction or the transaction that requires the interaction with the gateway's hosted payment page, and these transactions don't have the result.protected TransactionExecutionUtil
protected Optional<PaymentTransaction>
getTransactionRequiresHostedPaymentPageInteraction
(@NonNull Payment payment) protected Optional<PaymentTransaction>
getTransactionRequiring3DSVerification
(@NonNull Payment payment) protected TransactionResponseService
protected com.broadleafcommerce.common.extension.TypeFactory
protected boolean
protected PaymentTransaction
identifyParentTransactionIfExists
(com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService transactionService, Map<String, Object> transactionResults, Map<String, Object> additionalPaymentProperties, Payment payment) protected com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionResponseService
identifyTransactionResponseService
(@NonNull Payment payment) Identifies the relevantPaymentGatewayTransactionResponseService
based on the payment'sPayment.getGatewayType()
protected com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionResponseValidator
identifyTransactionResponseValidator
(@NonNull Payment payment) Identifies the relevantPaymentGatewayTransactionResponseValidator
based on the payment'sPayment.getGatewayType()
protected com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService
identifyTransactionService
(@NonNull Payment payment) Identifies the relevantPaymentGatewayTransactionService
based on the payment'sPayment.getGatewayType()
protected boolean
isIndeterminateResult
(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Determines whether or not the payment response represents an indeterminate result.prorateAmountDetails
(List<DefaultTransactionExecutionService.ParentTransactionExecutionPackage> executionPackages, javax.money.MonetaryAmount requestDetailAmount, javax.money.MonetaryAmount requestTransactionAmount) prorateTransactionAmountDetails
(@NonNull TransactionExecutionRequest request, List<DefaultTransactionExecutionService.ParentTransactionExecutionPackage> executionPackages) recordGatewayTransactionResults
(@NonNull String paymentId, @NonNull Map<String, Object> transactionResults, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Records transaction results that are processed by the gateway outside the checkout workflow.protected PaymentTransaction
recordImpliedReverseAuth
(@NonNull Payment payment, @NonNull PaymentTransaction captureTransaction, @NonNull PaymentTransaction parentAuthTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Payment
recordPaymentMethodPropertiesFromResponse
(@NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Stores thePaymentResponse.getPaymentMethodProperties()
on thePayment
and setsPayment.isSingleUsePaymentMethod()
to false ifPaymentResponse.getPaymentMethodProperties()
is not empty.protected PaymentTransaction
recordTransactionResponse
(@NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, @NonNull com.broadleafcommerce.paymentgateway.domain.enums.TransactionType transactionType, PaymentTransaction parentTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds and records a transaction based on thePayment
andPaymentResponse
.protected PaymentTransaction
recordTransactionResponse
(@NonNull PaymentTransaction transaction, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the givenPaymentTransaction
based on the givenPaymentResponse
and persists thePaymentTransaction
.refund
(@NonNull TransactionExecutionRequest request, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Communicates with the relevant payment gateway to execute aDefaultTransactionTypes.REFUND
transaction.reverseAuthorize
(@NonNull TransactionExecutionRequest request, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Communicates with the relevant payment gateway to execute aDefaultTransactionTypes.REVERSE_AUTH
transaction.void
setCustomerNotificationService
(PaymentCustomerNotificationService customerNotificationService) void
setMonetaryAmountRoundingHelper
(MonetaryAmountRoundingHelper monetaryAmountRoundingHelper) void
setSavedPaymentMethodManagementService
(SavedPaymentMethodManagementService savedPaymentMethodManagementService) void
setSavedPaymentMethodService
(SavedPaymentMethodService<SavedPaymentMethod> savedPaymentMethodService) protected boolean
shouldArchivePaymentDueToFailedTransaction
(@NonNull Payment payment, @NonNull PaymentTransaction transaction) Determines whether or not thePayment
should be archived due to the failed transaction that is described by the providedPaymentResponse
.protected boolean
shouldRecordImpliedReverseAuth
(@NonNull Payment payment, @NonNull PaymentTransaction captureTransaction, @NonNull PaymentTransaction parentAuthTransaction) protected boolean
shouldRecordPaymentMethodPropertiesFromResponse
(@NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Deprecated.since 1.0.2, no longer usedprotected Payment
updatePaymentBasedOnTransactionResult
(@NonNull Payment payment, @NonNull PaymentTransaction transaction, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Based on the results of the payment gateway authorize transaction, update the payment.updatePaymentBasedOnTransactionResult
(@NonNull Payment payment, @NonNull PaymentTransaction transaction, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Based on the results of the payment gateway authorize transaction, update thePayment
andSavedPaymentMethod
.protected void
updateSavedPaymentBasedOnPaymentResponse
(@NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the transaction execution details of theSavedPaymentMethod
for the givenPayment
.protected void
updateTransactionBasedOnResponse
(@NonNull PaymentTransaction transaction, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Updates the givenPaymentTransaction
based on the givenPaymentResponse
protected void
validateGatewayTransactionResponse
(@NonNull com.broadleafcommerce.paymentgateway.domain.GatewayTransactionResponse transactionResponse, @NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Checks whether or not theGatewayTransactionResponse
can validly be added to the payment.
-
Constructor Details
-
DefaultTransactionExecutionService
public DefaultTransactionExecutionService(PaymentService<Payment> paymentService, PaymentManagementService<Payment> paymentManagementService, TransactionExecutionRequestValidator requestValidator, PaymentLockService<Payment> paymentLockService, PaymentRequestService paymentRequestService, com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider paymentGatewayResourceProvider, PaymentTransactionService<PaymentTransaction> paymentTransactionService, TransactionResponseService transactionResponseService, TransactionExecutionUtil transactionExecutionUtil, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
authorize
public TransactionExecutionResponse authorize(@NonNull @NonNull TransactionExecutionRequest request, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:TransactionExecutionService
Communicates with the relevant payment gateway to execute anDefaultTransactionTypes.AUTHORIZE
transaction.- Specified by:
authorize
in interfaceTransactionExecutionService
- Parameters:
request
- TheTransactionExecutionRequest
describing the desired details of the transaction.lockToken
- Token granted to resource that owns the payment lock.- Returns:
- The
TransactionExecutionDetail
describing the resulting transaction andPaymentSummary
.
-
authorizeAndCapture
public TransactionExecutionResponse authorizeAndCapture(@NonNull @NonNull TransactionExecutionRequest request, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:TransactionExecutionService
Communicates with the relevant payment gateway to execute anDefaultTransactionTypes.AUTHORIZE_AND_CAPTURE
transaction.- Specified by:
authorizeAndCapture
in interfaceTransactionExecutionService
- Parameters:
request
- TheTransactionExecutionRequest
describing the desired details of the transaction.lockToken
- Token granted to resource that owns the payment lock.- Returns:
- The
TransactionExecutionDetail
describing the resulting transaction andPaymentSummary
.
-
capture
public TransactionExecutionResponse capture(@NonNull @NonNull TransactionExecutionRequest request, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:TransactionExecutionService
Communicates with the relevant payment gateway to execute aDefaultTransactionTypes.CAPTURE
transaction.- Specified by:
capture
in interfaceTransactionExecutionService
- Parameters:
request
- TheTransactionExecutionRequest
describing the desired details of the transaction.lockToken
- Token granted to resource that owns the payment lock.- Returns:
- The
TransactionExecutionDetail
describing the resulting transaction andPaymentSummary
.
-
reverseAuthorize
public TransactionExecutionResponse reverseAuthorize(@NonNull @NonNull TransactionExecutionRequest request, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:TransactionExecutionService
Communicates with the relevant payment gateway to execute aDefaultTransactionTypes.REVERSE_AUTH
transaction.- Specified by:
reverseAuthorize
in interfaceTransactionExecutionService
- Parameters:
request
- TheTransactionExecutionRequest
describing the desired details of the transaction.lockToken
- Token granted to resource that owns the payment lock.- Returns:
- The
TransactionExecutionDetail
describing the resulting transaction andPaymentSummary
.
-
refund
public TransactionExecutionResponse refund(@NonNull @NonNull TransactionExecutionRequest request, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:TransactionExecutionService
Communicates with the relevant payment gateway to execute aDefaultTransactionTypes.REFUND
transaction.- Specified by:
refund
in interfaceTransactionExecutionService
- Parameters:
request
- TheTransactionExecutionRequest
describing the desired details of the transaction.lockToken
- Token granted to resource that owns the payment lock.- Returns:
- The
TransactionExecutionDetail
describing the resulting transaction andPaymentSummary
.
-
detachedCredit
public TransactionExecutionResponse detachedCredit(@NonNull @NonNull TransactionExecutionRequest request, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:TransactionExecutionService
Communicates with the relevant payment gateway to execute aDefaultTransactionTypes.DETACHED_CREDIT
transaction.If
TransactionExecutionRequest.getParentTransactionId()
is provided, then we'll consider it to be acting as a refund. In this case, the parent transaction should haveDefaultTransactionTypes.CAPTURE
orDefaultTransactionTypes.AUTHORIZE_AND_CAPTURE
type, andTransactionExecutionRequest.getTransactionAmount()
must be less than or equal to the parent transaction's amount.- Specified by:
detachedCredit
in interfaceTransactionExecutionService
- Parameters:
request
- TheTransactionExecutionRequest
describing the desired details of the transaction.lockToken
- Token granted to resource that owns the payment lock.- Returns:
- The
TransactionExecutionDetail
describing the resulting transaction andPaymentSummary
.
-
recordGatewayTransactionResults
public TransactionExecutionResponse recordGatewayTransactionResults(@NonNull @NonNull String paymentId, @NonNull @NonNull Map<String, Object> transactionResults, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:TransactionExecutionService
Records transaction results that are processed by the gateway outside the checkout workflow.- Specified by:
recordGatewayTransactionResults
in interfaceTransactionExecutionService
- Parameters:
paymentId
- the ID of the payment for this transactiontransactionResults
- a map of the gateway's results for this transactioncontext
- Context information around sandbox and multitenant state.- Returns:
- The
TransactionExecutionResponse
describing the resulting transaction andPaymentSummary
.
-
buildGatewayTransactionResponse
protected com.broadleafcommerce.paymentgateway.domain.GatewayTransactionResponse buildGatewayTransactionResponse(@NonNull @NonNull Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.enums.TransactionType transactionType, @NonNull @NonNull Map<String, Object> transactionResults, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Builds aGatewayTransactionResponse
from the payment and including the gateway transaction results.- Parameters:
payment
- thePayment
that this transaction belongs totransactionType
- the transaction type that was executedtransactionResults
- the transaction results returned by the gatewaycontext
- context information related to multitenancy.- Returns:
- the
GatewayTransactionResponse
based on the payment and including the gateway transaction results
-
buildPaymentResponseFromTransactionResults
protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse buildPaymentResponseFromTransactionResults(@NonNull @NonNull Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.GatewayTransactionResponse gatewayTransactionResponse, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Builds aPaymentResponse
from the gateway transaction results.- Parameters:
payment
- thePayment
that this transaction belongs togatewayTransactionResponse
- the payment gateway's response to the transactioncontext
- context information related to multitenancy.- Returns:
- the
PaymentResponse
based on the gateway transaction results
-
updatePaymentBasedOnTransactionResult
@Nullable public Payment updatePaymentBasedOnTransactionResult(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction transaction, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Based on the results of the payment gateway authorize transaction, update thePayment
andSavedPaymentMethod
.- Specified by:
updatePaymentBasedOnTransactionResult
in interfaceTransactionExecutionService
- Parameters:
payment
- the payment that is to be updated based on the transactiontransaction
- the transaction that was just executedresponse
- the payment gateway's response to the transactionlockToken
- Token granted to resource that owns the payment lock.contextInfo
- Context information related to multitenancy.- Returns:
- the updated payment
-
getTransactionExecutionResponse
protected Optional<TransactionExecutionResponse> getTransactionExecutionResponse(@NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull Payment payment, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns the transaction execution response, if the payment has the 3DS transaction or the transaction that requires the interaction with the gateway's hosted payment page, and these transactions don't have the result.- Parameters:
request
- TheTransactionExecutionRequest
describing the desired details of the transactionpayment
- The payment to search the transactionscontextInfo
- Context information used to discriminate the correct version of an entity by context id when multiple versions may be available across sandboxes, catalogs and applications- Returns:
- a transaction execution response, if any
-
getTransactionRequiring3DSVerification
protected Optional<PaymentTransaction> getTransactionRequiring3DSVerification(@NonNull @NonNull Payment payment) -
getTransactionRequiresHostedPaymentPageInteraction
protected Optional<PaymentTransaction> getTransactionRequiresHostedPaymentPageInteraction(@NonNull @NonNull Payment payment) -
executeAgainstParentTransactions
protected TransactionExecutionResponse executeAgainstParentTransactions(@NonNull @NonNull TransactionExecutionRequest request, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds and executes the givenTransactionExecutionRequest
against parent transactions.This is used for
TransactionTypes
that require proceeding transactions. For example,DefaultTransactionTypes.REFUND
requires a proceedingDefaultTransactionTypes.CAPTURE
, this method looks for all the capture transactions and execute refund against them based on the givenTransactionExecutionRequest
.Note that out-of-box, the scenario of having multiple parent transactions is very unlikely and not expected, however it is supported.
- Parameters:
request
- theTransactionExecutionRequest
to executelockToken
- Token granted to resource that owns the payment lock.contextInfo
- context information surrounding multitenant state- Returns:
- a
TransactionExecutionResponse
representing the execution result of the givenTransactionExecutionRequest
-
hasTransactionAmountDetails
-
prorateTransactionAmountDetails
protected List<DefaultTransactionExecutionService.ParentTransactionExecutionPackage> prorateTransactionAmountDetails(@NonNull @NonNull TransactionExecutionRequest request, List<DefaultTransactionExecutionService.ParentTransactionExecutionPackage> executionPackages) -
prorateAmountDetails
protected Map<String,javax.money.MonetaryAmount> prorateAmountDetails(List<DefaultTransactionExecutionService.ParentTransactionExecutionPackage> executionPackages, javax.money.MonetaryAmount requestDetailAmount, javax.money.MonetaryAmount requestTransactionAmount) -
calculateProratedAmount
protected javax.money.MonetaryAmount calculateProratedAmount(javax.money.MonetaryAmount requestDetailTotal, javax.money.MonetaryAmount transactionAmount, javax.money.MonetaryAmount requestTransactionAmount) -
getPaymentTransactionById
protected PaymentTransaction getPaymentTransactionById(@NonNull @NonNull Payment payment, @NonNull @NonNull String parentTransactionId) -
getParentTransactionExecutionPackages
protected List<DefaultTransactionExecutionService.ParentTransactionExecutionPackage> getParentTransactionExecutionPackages(TransactionExecutionRequest request, List<TransactionWithExecutableAmount> parentTransactions, javax.money.MonetaryAmount totalToExecute, Payment payment, com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService transactionService, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets a list ofParentTransactionExecutionPackages
based on the given parameters.- Parameters:
parentTransactions
- a list ofTransactionWithExecutableAmounts
representing parent transactions and their executable amountstotalToExecute
- total amount to executepayment
- the relatedPayment
that the transactions are acting againsttransactionService
- the relevantPaymentGatewayTransactionService
based on the payment'sPayment.getGatewayType()
contextInfo
- context information surrounding multitenant state- Returns:
- a list of
ParentTransactionExecutionPackages
based on the given parameters
-
findFirstExecutableParentTransaction
protected TransactionWithExecutableAmount findFirstExecutableParentTransaction(List<TransactionWithExecutableAmount> parentTransactions, String paymentId) Finds the firstTransactionWithExecutableAmount
with amount available to execute.- Parameters:
parentTransactions
- a list ofTransactionWithExecutableAmounts
to look frompaymentId
- the relatedPayment.getId()
that the parent transactions belong to- Returns:
- the first
TransactionWithExecutableAmount
with amount available to execute - Throws:
PaymentTransactionExecutionException
- if noTransactionWithExecutableAmount
is found with available amount for execution
-
executeAgainstParentTransaction
protected org.apache.commons.lang3.tuple.Pair<Payment,TransactionExecutionDetail> executeAgainstParentTransaction(@NonNull @NonNull Payment payment, @NonNull @NonNull DefaultTransactionExecutionService.ParentTransactionExecutionPackage executionPackage, @Nullable String lockToken) Executes the givenDefaultTransactionExecutionService.ParentTransactionExecutionPackage
.- Parameters:
payment
- the most up-to-datePayment
executionPackage
- theDefaultTransactionExecutionService.ParentTransactionExecutionPackage
containing all the relevant data for transaction executionlockToken
- Token granted to resource that owns the payment lock.- Returns:
- the pair of
TransactionExecutionDetail
representing the execution result of the givenDefaultTransactionExecutionService.ParentTransactionExecutionPackage
and updatedPayment
-
executePaymentRequest
@Deprecated(forRemoval=true) protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse executePaymentRequest(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest, @NonNull @NonNull com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService transactionService, @NonNull @NonNull TransactionExecutionRequest executionRequest) Deprecated, for removal: This API element is subject to removal in a future version.Executes the givenPaymentRequest
based on the givenTransactionExecutionRequest
against the givenPaymentGatewayTransactionService
.- Parameters:
paymentRequest
- thePaymentRequest
to executetransactionService
- thePaymentGatewayTransactionService
to execute thePaymentRequest
againstexecutionRequest
- the originalTransactionExecutionRequest
that thePaymentRequest
created from- Returns:
- the
PaymentResponse
from the execution result
-
executePaymentRequest
protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse executePaymentRequest(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest, @NonNull @NonNull com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService transactionService, @NonNull @NonNull TransactionExecutionRequest executionRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getTransactionExecutionFunction
protected Function<com.broadleafcommerce.paymentgateway.domain.PaymentRequest,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> getTransactionExecutionFunction(@NonNull @NonNull TransactionExecutionRequest request, com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService transactionService) Gets a transaction executionFunction
based on the givenTransactionExecutionRequest.getTransactionType()
and the givenPaymentGatewayTransactionService
.- Parameters:
request
- theTransactionExecutionRequest
to get theTransactionExecutionRequest.getTransactionType()
fromtransactionService
- thePaymentGatewayTransactionService
to find the execution method from- Returns:
- a transaction execution
Function
based on the givenTransactionExecutionRequest.getTransactionType()
and the givenPaymentGatewayTransactionService
- Throws:
PaymentTransactionExecutionException
- if the givenTransactionExecutionRequest.getTransactionType()
does not match any methods in the givenPaymentGatewayTransactionService
-
validateGatewayTransactionResponse
protected void validateGatewayTransactionResponse(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.GatewayTransactionResponse transactionResponse, @NonNull @NonNull Payment payment, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Checks whether or not theGatewayTransactionResponse
can validly be added to the payment.- Parameters:
transactionResponse
- TheGatewayTransactionResponse
to be checked.payment
- The relatedPayment
that the request will act against.contextInfo
- Context information related to multitenancy.- Throws:
InvalidTransactionExecutionRequestException
- if theGatewayTransactionResponse
is invalid.
-
identifyTransactionResponseValidator
protected com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionResponseValidator identifyTransactionResponseValidator(@NonNull @NonNull Payment payment) Identifies the relevantPaymentGatewayTransactionResponseValidator
based on the payment'sPayment.getGatewayType()
- Parameters:
payment
- the payment object that contains a reference to the required transaction service- Returns:
- the identified PaymentGatewayTransactionResponseValidator
-
identifyTransactionResponseService
protected com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionResponseService identifyTransactionResponseService(@NonNull @NonNull Payment payment) Identifies the relevantPaymentGatewayTransactionResponseService
based on the payment'sPayment.getGatewayType()
- Parameters:
payment
- the payment object that contains a reference to the required transaction service- Returns:
- the identified PaymentGatewayTransactionResponseService
-
buildAdditionalPaymentProperties
Hookpoint for populating information from the payment to identify a parent transaction for the gateway. Override this method to add additional properties.- Parameters:
payment
- the payment object for the request- Returns:
- a map of payment-related properties
-
identifyParentTransactionIfExists
-
identifyTransactionService
protected com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService identifyTransactionService(@NonNull @NonNull Payment payment) Identifies the relevantPaymentGatewayTransactionService
based on the payment'sPayment.getGatewayType()
- Parameters:
payment
- The relatedPayment
that the request will act against.- Returns:
- the identified PaymentGatewayTransactionService
-
createPaymentTransaction
protected PaymentTransaction createPaymentTransaction(@NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull Payment payment, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
createPaymentTransaction
protected PaymentTransaction createPaymentTransaction(@NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull Payment payment, @Nullable PaymentTransaction parentTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
createPaymentTransaction
protected PaymentTransaction createPaymentTransaction(@NonNull @NonNull javax.money.MonetaryAmount transactionAmount, @NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull Payment payment, @Nullable PaymentTransaction parentTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
createPaymentTransaction
protected PaymentTransaction createPaymentTransaction(@NonNull @NonNull TransactionAmountDetails transactionAmountDetails, @NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull Payment payment, @Nullable PaymentTransaction parentTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
recordTransactionResponse
protected PaymentTransaction recordTransactionResponse(@NonNull @NonNull PaymentTransaction transaction, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the givenPaymentTransaction
based on the givenPaymentResponse
and persists thePaymentTransaction
.- Parameters:
transaction
- thePaymentTransaction
to update and persistresponse
- thePaymentResponse
to get the data fromcontextInfo
- context information related to multitenancy- Returns:
- updated and persisted
PaymentTransaction
-
updateTransactionBasedOnResponse
protected void updateTransactionBasedOnResponse(@NonNull @NonNull PaymentTransaction transaction, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Updates the givenPaymentTransaction
based on the givenPaymentResponse
- Parameters:
transaction
- thePaymentTransaction
to updateresponse
- thePaymentResponse
to get the data from
-
determineTransactionStatus
protected String determineTransactionStatus(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Determines the new status of thePaymentTransaction
based on the contents of thePaymentResponse
- Parameters:
response
- the payment gateway's response to the executed transaction- Returns:
- the new status of the
PaymentTransaction
based on the contents of thePaymentResponse
-
shouldRecordImpliedReverseAuth
protected boolean shouldRecordImpliedReverseAuth(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction captureTransaction, @NonNull @NonNull PaymentTransaction parentAuthTransaction) -
recordImpliedReverseAuth
protected PaymentTransaction recordImpliedReverseAuth(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction captureTransaction, @NonNull @NonNull PaymentTransaction parentAuthTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
createSavedPaymentMethodIfNeeded
protected void createSavedPaymentMethodIfNeeded(@NonNull @NonNull Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Creates a saved payment method via the registered implementation ofSavedPaymentMethodManagementService
from the givenPayment
if necessary.- Parameters:
payment
- the payment that should be savedpaymentResponse
- thePaymentResponse
from the transaction executioncontextInfo
- Context information related to multitenancy
-
updatePaymentBasedOnTransactionResult
@Nullable protected Payment updatePaymentBasedOnTransactionResult(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction transaction, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Based on the results of the payment gateway authorize transaction, update the payment.- Parameters:
payment
- the payment that is to be updated based on the transactiontransaction
- the transaction that was just executedresponse
- the payment gateway's response to the transactioncontextInfo
- Context information related to multitenancy.- Returns:
- the updated payment
-
shouldArchivePaymentDueToFailedTransaction
protected boolean shouldArchivePaymentDueToFailedTransaction(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction transaction) Determines whether or not thePayment
should be archived due to the failed transaction that is described by the providedPaymentResponse
. Note: Archiving the payment declares that it can no longer contribute to a successful checkout.- Parameters:
payment
- the payment that may be archived based on the results of this methodtransaction
- the result of the executed transaction- Returns:
- whether or not the payment should be archived due to the failed transaction
-
shouldRecordPaymentMethodPropertiesFromResponse
@Deprecated protected boolean shouldRecordPaymentMethodPropertiesFromResponse(@NonNull @NonNull Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Deprecated.since 1.0.2, no longer usedDecides whether thePaymentResponse.getPaymentMethodProperties()
should be stored on thePayment
. Typically, this would only be done to record new payment method properties that were created during the execution of a transaction. For example, creating a multi-use token while executing an initial authorize transaction.- Parameters:
payment
- the payment that is to be updated based on the transaction resultresponse
- the payment gateway's response to the transaction- Returns:
- whether the
PaymentResponse.getPaymentMethodProperties()
should be stored on thePayment
.
-
recordPaymentMethodPropertiesFromResponse
protected Payment recordPaymentMethodPropertiesFromResponse(@NonNull @NonNull Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Stores thePaymentResponse.getPaymentMethodProperties()
on thePayment
and setsPayment.isSingleUsePaymentMethod()
to false ifPaymentResponse.getPaymentMethodProperties()
is not empty. Typically, this would only be done to record new payment method properties that were created during the execution of a transaction. For example, creating a multi-use token while executing an initial authorize transaction.- Parameters:
payment
- the payment that is to be updated based on the transaction resultresponse
- the payment gateway's response to the transaction- Returns:
- The updated
Payment
-
updateSavedPaymentBasedOnPaymentResponse
protected void updateSavedPaymentBasedOnPaymentResponse(@NonNull @NonNull Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the transaction execution details of theSavedPaymentMethod
for the givenPayment
.- Parameters:
payment
- thePayment
that potentially has aSavedPaymentMethod
response
- thePaymentResponse
from the transaction executioncontextInfo
- context information related to multitenancy.
-
isIndeterminateResult
protected boolean isIndeterminateResult(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Determines whether or not the payment response represents an indeterminate result.For example, if a network error occurred, it we won't know if the transaction was completed or not on the gateway side of things.
- Parameters:
response
- the payment gateway's response to the executed transaction- Returns:
- whether the response yielded an indeterminate payment response or not
-
buildPaymentRef
-
recordTransactionResponse
protected PaymentTransaction recordTransactionResponse(@NonNull @NonNull Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.enums.TransactionType transactionType, @Nullable PaymentTransaction parentTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds and records a transaction based on thePayment
andPaymentResponse
.- Parameters:
payment
- the payment that is to be updated based on the transactionresponse
- the payment gateway's response to the executed transactiontransactionType
- the transaction type that was executedparentTransaction
- the payment transaction that proceeded the transaction being processedcontextInfo
- Context information around sandbox and multitenant state.- Returns:
- The recorded
PaymentTransaction
based on the givenPaymentResponse
-
getExisting3DSTransactionResult
protected Optional<PaymentTransaction> getExisting3DSTransactionResult(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction parentTransaction) -
getApplicationIdFromContext
@Nullable protected String getApplicationIdFromContext(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getTenantIdFromContext
@Nullable protected String getTenantIdFromContext(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getPaymentService
-
getPaymentManagementService
-
getRequestValidator
-
getPaymentLockService
-
getPaymentRequestService
-
getPaymentGatewayResourceProvider
protected com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider getPaymentGatewayResourceProvider() -
getPaymentTransactionService
-
getTransactionResponseService
-
getTransactionExecutionUtil
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getSavedPaymentMethodManagementService
-
setSavedPaymentMethodManagementService
@Autowired public void setSavedPaymentMethodManagementService(SavedPaymentMethodManagementService savedPaymentMethodManagementService) -
getMonetaryAmountRoundingHelper
-
setMonetaryAmountRoundingHelper
@Autowired public void setMonetaryAmountRoundingHelper(MonetaryAmountRoundingHelper monetaryAmountRoundingHelper) -
getSavedPaymentMethodService
-
setSavedPaymentMethodService
@Autowired(required=false) public void setSavedPaymentMethodService(@Nullable SavedPaymentMethodService<SavedPaymentMethod> savedPaymentMethodService) -
getCustomerNotificationService
-
setCustomerNotificationService
@Autowired public void setCustomerNotificationService(PaymentCustomerNotificationService customerNotificationService)
-
executePaymentRequest(PaymentRequest, PaymentGatewayTransactionService, TransactionExecutionRequest, ContextInfo)