Class DefaultTransactionExecutionService
- All Implemented Interfaces:
TransactionExecutionService
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn intermediary data structure used internally byTransactionExecutionServiceto hold all the relevant data to execute a transaction against aparent transaction. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultTransactionExecutionService(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.AUTHORIZEtransaction.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_CAPTUREtransaction.buildAdditionalPaymentProperties(Payment payment) Hookpoint for populating information from the payment to identify a parent transaction for the gateway.protected com.broadleafcommerce.paymentgateway.domain.GatewayTransactionResponsebuildGatewayTransactionResponse(@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 aGatewayTransactionResponsefrom the payment and including the gateway transaction results.protected com.broadleafcommerce.paymentgateway.domain.PaymentInfobuildPaymentInfo(@NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected PaymentRefbuildPaymentRef(Payment payment) protected com.broadleafcommerce.paymentgateway.domain.PaymentResponsebuildPaymentResponseFromTransactionResults(@NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.GatewayTransactionResponse gatewayTransactionResponse, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Builds aPaymentResponsefrom the gateway transaction results.protected javax.money.MonetaryAmountcalculateProratedAmount(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.CAPTUREtransaction.protected PaymentTransactioncreatePaymentTransaction(@NonNull TransactionAmountDetails transactionAmountDetails, @NonNull TransactionExecutionRequest request, @NonNull Payment payment, PaymentTransaction parentTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransactioncreatePaymentTransaction(@NonNull TransactionExecutionRequest request, @NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransactioncreatePaymentTransaction(@NonNull TransactionExecutionRequest request, @NonNull Payment payment, PaymentTransaction parentTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransactioncreatePaymentTransaction(@NonNull javax.money.MonetaryAmount transactionAmount, @NonNull TransactionExecutionRequest request, @NonNull Payment payment, PaymentTransaction parentTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidcreateSavedPaymentMethodIfNeeded(@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 ofSavedPaymentMethodManagementServicefrom the givenPaymentif 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_CREDITtransaction.protected StringdetermineTransactionStatus(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Determines the new status of thePaymentTransactionbased on the contents of thePaymentResponseprotected org.apache.commons.lang3.tuple.Pair<Payment,TransactionExecutionDetail> executeAgainstParentTransaction(@NonNull Payment payment, @NonNull DefaultTransactionExecutionService.ParentTransactionExecutionPackage executionPackage, String lockToken) Executes the givenDefaultTransactionExecutionService.ParentTransactionExecutionPackage.protected TransactionExecutionResponseexecuteAgainstParentTransactions(@NonNull TransactionExecutionRequest request, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds and executes the givenTransactionExecutionRequestagainst parent transactions.protected com.broadleafcommerce.paymentgateway.domain.PaymentResponseexecutePaymentRequest(@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.PaymentResponseexecutePaymentRequest(@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 TransactionWithExecutableAmountfindFirstExecutableParentTransaction(List<TransactionWithExecutableAmount> parentTransactions, String paymentId) Finds the firstTransactionWithExecutableAmountwith amount available to execute.protected StringgetApplicationIdFromContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentCustomerNotificationServiceprotected Optional<PaymentTransaction>getExisting3DSTransactionResult(@NonNull Payment payment, @NonNull PaymentTransaction parentTransaction) protected MonetaryAmountRoundingHelpergetParentTransactionExecutionPackages(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 ofParentTransactionExecutionPackagesbased on the given parameters.protected com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProviderprotected PaymentLockService<Payment>protected PaymentManagementService<Payment>protected PaymentRequestServiceprotected PaymentService<Payment>protected PaymentTransactiongetPaymentTransactionById(@NonNull Payment payment, @NonNull String parentTransactionId) protected PaymentTransactionService<PaymentTransaction>protected TransactionExecutionRequestValidatorprotected SavedPaymentMethodManagementServiceprotected SavedPaymentMethodService<SavedPaymentMethod>protected StringgetTenantIdFromContext(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 executionFunctionbased 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 TransactionExecutionUtilprotected StringgetTransactionReferenceId(@NonNull TransactionExecutionRequest request, @NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Optional<PaymentTransaction>getTransactionRequiresHostedPaymentPageInteraction(@NonNull Payment payment) protected Optional<PaymentTransaction>getTransactionRequiring3DSVerification(@NonNull Payment payment) protected TransactionResponseServiceprotected com.broadleafcommerce.common.extension.TypeFactoryprotected booleanprotected PaymentTransactionidentifyParentTransactionIfExists(com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService transactionService, Map<String, Object> transactionResults, Map<String, Object> additionalPaymentProperties, Payment payment) protected com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionResponseServiceidentifyTransactionResponseService(@NonNull Payment payment) Identifies the relevantPaymentGatewayTransactionResponseServicebased on the payment'sPayment.getGatewayType()protected com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionResponseValidatoridentifyTransactionResponseValidator(@NonNull Payment payment) Identifies the relevantPaymentGatewayTransactionResponseValidatorbased on the payment'sPayment.getGatewayType()protected com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionServiceidentifyTransactionService(@NonNull Payment payment) Identifies the relevantPaymentGatewayTransactionServicebased on the payment'sPayment.getGatewayType()protected booleanisIndeterminateResult(@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 PaymentTransactionrecordImpliedReverseAuth(@NonNull Payment payment, @NonNull PaymentTransaction captureTransaction, @NonNull PaymentTransaction parentAuthTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentrecordPaymentMethodPropertiesFromResponse(@NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Stores thePaymentResponse.getPaymentMethodProperties()on thePaymentand setsPayment.isSingleUsePaymentMethod()to false ifPaymentResponse.getPaymentMethodProperties()is not empty.protected PaymentTransactionrecordTransactionResponse(@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 thePaymentandPaymentResponse.protected PaymentTransactionrecordTransactionResponse(@NonNull PaymentTransaction transaction, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the givenPaymentTransactionbased on the givenPaymentResponseand 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.REFUNDtransaction.reverseAuthorize(@NonNull TransactionExecutionRequest request, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Communicates with the relevant payment gateway to execute aDefaultTransactionTypes.REVERSE_AUTHtransaction.voidsetCustomerNotificationService(PaymentCustomerNotificationService customerNotificationService) voidsetMonetaryAmountRoundingHelper(MonetaryAmountRoundingHelper monetaryAmountRoundingHelper) voidsetSavedPaymentMethodManagementService(SavedPaymentMethodManagementService savedPaymentMethodManagementService) voidsetSavedPaymentMethodService(SavedPaymentMethodService<SavedPaymentMethod> savedPaymentMethodService) protected booleanshouldArchivePaymentDueToFailedTransaction(@NonNull Payment payment, @NonNull PaymentTransaction transaction) Determines whether or not thePaymentshould be archived due to the failed transaction that is described by the providedPaymentResponse.protected booleanshouldRecordImpliedReverseAuth(@NonNull Payment payment, @NonNull PaymentTransaction captureTransaction, @NonNull PaymentTransaction parentAuthTransaction) protected booleanshouldRecordPaymentMethodPropertiesFromResponse(@NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Deprecated.since 1.0.2, no longer usedprotected PaymentupdatePaymentBasedOnTransactionResult(@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 thePaymentandSavedPaymentMethod.protected voidupdateSavedPaymentBasedOnPaymentResponse(@NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the transaction execution details of theSavedPaymentMethodfor the givenPayment.protected voidupdateTransactionBasedOnResponse(@NonNull PaymentTransaction transaction, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Updates the givenPaymentTransactionbased on the givenPaymentResponseprotected voidvalidateGatewayTransactionResponse(@NonNull com.broadleafcommerce.paymentgateway.domain.GatewayTransactionResponse transactionResponse, @NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Checks whether or not theGatewayTransactionResponsecan 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:TransactionExecutionServiceCommunicates with the relevant payment gateway to execute anDefaultTransactionTypes.AUTHORIZEtransaction.- Specified by:
authorizein interfaceTransactionExecutionService- Parameters:
request- TheTransactionExecutionRequestdescribing the desired details of the transaction.lockToken- Token granted to resource that owns the payment lock.- Returns:
- The
TransactionExecutionDetaildescribing 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:TransactionExecutionServiceCommunicates with the relevant payment gateway to execute anDefaultTransactionTypes.AUTHORIZE_AND_CAPTUREtransaction.- Specified by:
authorizeAndCapturein interfaceTransactionExecutionService- Parameters:
request- TheTransactionExecutionRequestdescribing the desired details of the transaction.lockToken- Token granted to resource that owns the payment lock.- Returns:
- The
TransactionExecutionDetaildescribing 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:TransactionExecutionServiceCommunicates with the relevant payment gateway to execute aDefaultTransactionTypes.CAPTUREtransaction.- Specified by:
capturein interfaceTransactionExecutionService- Parameters:
request- TheTransactionExecutionRequestdescribing the desired details of the transaction.lockToken- Token granted to resource that owns the payment lock.- Returns:
- The
TransactionExecutionDetaildescribing 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:TransactionExecutionServiceCommunicates with the relevant payment gateway to execute aDefaultTransactionTypes.REVERSE_AUTHtransaction.- Specified by:
reverseAuthorizein interfaceTransactionExecutionService- Parameters:
request- TheTransactionExecutionRequestdescribing the desired details of the transaction.lockToken- Token granted to resource that owns the payment lock.- Returns:
- The
TransactionExecutionDetaildescribing 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:TransactionExecutionServiceCommunicates with the relevant payment gateway to execute aDefaultTransactionTypes.REFUNDtransaction.- Specified by:
refundin interfaceTransactionExecutionService- Parameters:
request- TheTransactionExecutionRequestdescribing the desired details of the transaction.lockToken- Token granted to resource that owns the payment lock.- Returns:
- The
TransactionExecutionDetaildescribing 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:TransactionExecutionServiceCommunicates with the relevant payment gateway to execute aDefaultTransactionTypes.DETACHED_CREDITtransaction.If
TransactionExecutionRequest.getParentTransactionId()is provided, then we'll consider it to be acting as a refund. In this case, the parent transaction should haveDefaultTransactionTypes.CAPTUREorDefaultTransactionTypes.AUTHORIZE_AND_CAPTUREtype, andTransactionExecutionRequest.getTransactionAmount()must be less than or equal to the parent transaction's amount.- Specified by:
detachedCreditin interfaceTransactionExecutionService- Parameters:
request- TheTransactionExecutionRequestdescribing the desired details of the transaction.lockToken- Token granted to resource that owns the payment lock.- Returns:
- The
TransactionExecutionDetaildescribing 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:TransactionExecutionServiceRecords transaction results that are processed by the gateway outside the checkout workflow.- Specified by:
recordGatewayTransactionResultsin 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
TransactionExecutionResponsedescribing 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 aGatewayTransactionResponsefrom the payment and including the gateway transaction results.- Parameters:
payment- thePaymentthat this transaction belongs totransactionType- the transaction type that was executedtransactionResults- the transaction results returned by the gatewaycontext- context information related to multitenancy.- Returns:
- the
GatewayTransactionResponsebased 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 aPaymentResponsefrom the gateway transaction results.- Parameters:
payment- thePaymentthat this transaction belongs togatewayTransactionResponse- the payment gateway's response to the transactioncontext- context information related to multitenancy.- Returns:
- the
PaymentResponsebased 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 thePaymentandSavedPaymentMethod.- Specified by:
updatePaymentBasedOnTransactionResultin 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- TheTransactionExecutionRequestdescribing 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 givenTransactionExecutionRequestagainst parent transactions.This is used for
TransactionTypesthat require proceeding transactions. For example,DefaultTransactionTypes.REFUNDrequires 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- theTransactionExecutionRequestto executelockToken- Token granted to resource that owns the payment lock.contextInfo- context information surrounding multitenant state- Returns:
- a
TransactionExecutionResponserepresenting 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, @Nullable 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 ofParentTransactionExecutionPackagesbased on the given parameters.- Parameters:
parentTransactions- a list ofTransactionWithExecutableAmountsrepresenting parent transactions and their executable amountstotalToExecute- total amount to executepayment- the relatedPaymentthat the transactions are acting againsttransactionService- the relevantPaymentGatewayTransactionServicebased on the payment'sPayment.getGatewayType()contextInfo- context information surrounding multitenant state- Returns:
- a list of
ParentTransactionExecutionPackagesbased on the given parameters
-
findFirstExecutableParentTransaction
protected TransactionWithExecutableAmount findFirstExecutableParentTransaction(List<TransactionWithExecutableAmount> parentTransactions, String paymentId) Finds the firstTransactionWithExecutableAmountwith amount available to execute.- Parameters:
parentTransactions- a list ofTransactionWithExecutableAmountsto look frompaymentId- the relatedPayment.getId()that the parent transactions belong to- Returns:
- the first
TransactionWithExecutableAmountwith amount available to execute - Throws:
PaymentTransactionExecutionException- if noTransactionWithExecutableAmountis 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-datePaymentexecutionPackage- theDefaultTransactionExecutionService.ParentTransactionExecutionPackagecontaining all the relevant data for transaction executionlockToken- Token granted to resource that owns the payment lock.- Returns:
- the pair of
TransactionExecutionDetailrepresenting the execution result of the givenDefaultTransactionExecutionService.ParentTransactionExecutionPackageand 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 givenPaymentRequestbased on the givenTransactionExecutionRequestagainst the givenPaymentGatewayTransactionService.- Parameters:
paymentRequest- thePaymentRequestto executetransactionService- thePaymentGatewayTransactionServiceto execute thePaymentRequestagainstexecutionRequest- the originalTransactionExecutionRequestthat thePaymentRequestcreated from- Returns:
- the
PaymentResponsefrom 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 executionFunctionbased on the givenTransactionExecutionRequest.getTransactionType()and the givenPaymentGatewayTransactionService.- Parameters:
request- theTransactionExecutionRequestto get theTransactionExecutionRequest.getTransactionType()fromtransactionService- thePaymentGatewayTransactionServiceto find the execution method from- Returns:
- a transaction execution
Functionbased 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 theGatewayTransactionResponsecan validly be added to the payment.- Parameters:
transactionResponse- TheGatewayTransactionResponseto be checked.payment- The relatedPaymentthat the request will act against.contextInfo- Context information related to multitenancy.- Throws:
InvalidTransactionExecutionRequestException- if theGatewayTransactionResponseis invalid.
-
identifyTransactionResponseValidator
protected com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionResponseValidator identifyTransactionResponseValidator(@NonNull @NonNull Payment payment) Identifies the relevantPaymentGatewayTransactionResponseValidatorbased 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 relevantPaymentGatewayTransactionResponseServicebased 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 relevantPaymentGatewayTransactionServicebased on the payment'sPayment.getGatewayType()- Parameters:
payment- The relatedPaymentthat 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) -
getTransactionReferenceId
protected String getTransactionReferenceId(@NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull Payment payment, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
buildPaymentInfo
protected com.broadleafcommerce.paymentgateway.domain.PaymentInfo buildPaymentInfo(@NonNull @NonNull Payment payment, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) -
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 givenPaymentTransactionbased on the givenPaymentResponseand persists thePaymentTransaction.- Parameters:
transaction- thePaymentTransactionto update and persistresponse- thePaymentResponseto 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 givenPaymentTransactionbased on the givenPaymentResponse- Parameters:
transaction- thePaymentTransactionto updateresponse- thePaymentResponseto get the data from
-
determineTransactionStatus
protected String determineTransactionStatus(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Determines the new status of thePaymentTransactionbased on the contents of thePaymentResponse- Parameters:
response- the payment gateway's response to the executed transaction- Returns:
- the new status of the
PaymentTransactionbased 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 ofSavedPaymentMethodManagementServicefrom the givenPaymentif necessary.- Parameters:
payment- the payment that should be savedpaymentResponse- thePaymentResponsefrom 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 thePaymentshould 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 thePaymentand 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 theSavedPaymentMethodfor the givenPayment.- Parameters:
payment- thePaymentthat potentially has aSavedPaymentMethodresponse- thePaymentResponsefrom 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 thePaymentandPaymentResponse.- 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
PaymentTransactionbased 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)