Class DefaultTransactionExecutionService
- All Implemented Interfaces:
- TransactionExecutionService
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classAn intermediary data structure used internally byTransactionExecutionServiceto hold all the relevant data to execute a transaction against aparent transaction.
- 
Constructor SummaryConstructorsConstructorDescriptionDefaultTransactionExecutionService(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 SummaryModifier 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 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 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- 
DefaultTransactionExecutionServicepublic 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- 
authorizepublic 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 interface- TransactionExecutionService
- Parameters:
- request- The- TransactionExecutionRequestdescribing the desired details of the transaction.
- lockToken- Token granted to resource that owns the payment lock.
- Returns:
- The TransactionExecutionDetaildescribing the resulting transaction andPaymentSummary.
 
- 
authorizeAndCapturepublic 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 interface- TransactionExecutionService
- Parameters:
- request- The- TransactionExecutionRequestdescribing the desired details of the transaction.
- lockToken- Token granted to resource that owns the payment lock.
- Returns:
- The TransactionExecutionDetaildescribing the resulting transaction andPaymentSummary.
 
- 
capturepublic 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 interface- TransactionExecutionService
- Parameters:
- request- The- TransactionExecutionRequestdescribing the desired details of the transaction.
- lockToken- Token granted to resource that owns the payment lock.
- Returns:
- The TransactionExecutionDetaildescribing the resulting transaction andPaymentSummary.
 
- 
reverseAuthorizepublic 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 interface- TransactionExecutionService
- Parameters:
- request- The- TransactionExecutionRequestdescribing the desired details of the transaction.
- lockToken- Token granted to resource that owns the payment lock.
- Returns:
- The TransactionExecutionDetaildescribing the resulting transaction andPaymentSummary.
 
- 
refundpublic 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 interface- TransactionExecutionService
- Parameters:
- request- The- TransactionExecutionRequestdescribing the desired details of the transaction.
- lockToken- Token granted to resource that owns the payment lock.
- Returns:
- The TransactionExecutionDetaildescribing the resulting transaction andPaymentSummary.
 
- 
detachedCreditpublic 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 interface- TransactionExecutionService
- Parameters:
- request- The- TransactionExecutionRequestdescribing the desired details of the transaction.
- lockToken- Token granted to resource that owns the payment lock.
- Returns:
- The TransactionExecutionDetaildescribing the resulting transaction andPaymentSummary.
 
- 
recordGatewayTransactionResultspublic 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 interface- TransactionExecutionService
- Parameters:
- paymentId- the ID of the payment for this transaction
- transactionResults- a map of the gateway's results for this transaction
- context- Context information around sandbox and multitenant state.
- Returns:
- The TransactionExecutionResponsedescribing the resulting transaction andPaymentSummary.
 
- 
buildGatewayTransactionResponseprotected 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- the- Paymentthat this transaction belongs to
- transactionType- the transaction type that was executed
- transactionResults- the transaction results returned by the gateway
- context- context information related to multitenancy.
- Returns:
- the GatewayTransactionResponsebased on the payment and including the gateway transaction results
 
- 
buildPaymentResponseFromTransactionResultsprotected 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- the- Paymentthat this transaction belongs to
- gatewayTransactionResponse- the payment gateway's response to the transaction
- context- 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 interface- TransactionExecutionService
- Parameters:
- payment- the payment that is to be updated based on the transaction
- transaction- the transaction that was just executed
- response- the payment gateway's response to the transaction
- lockToken- Token granted to resource that owns the payment lock.
- contextInfo- Context information related to multitenancy.
- Returns:
- the updated payment
 
- 
getTransactionExecutionResponseprotected 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- The- TransactionExecutionRequestdescribing the desired details of the transaction
- payment- The payment to search the transactions
- contextInfo- 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
 
- 
getTransactionRequiring3DSVerificationprotected Optional<PaymentTransaction> getTransactionRequiring3DSVerification(@NonNull @NonNull Payment payment) 
- 
getTransactionRequiresHostedPaymentPageInteractionprotected Optional<PaymentTransaction> getTransactionRequiresHostedPaymentPageInteraction(@NonNull @NonNull Payment payment) 
- 
executeAgainstParentTransactionsprotected 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- the- TransactionExecutionRequestto execute
- lockToken- 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
- 
prorateTransactionAmountDetailsprotected List<DefaultTransactionExecutionService.ParentTransactionExecutionPackage> prorateTransactionAmountDetails(@NonNull @NonNull TransactionExecutionRequest request, List<DefaultTransactionExecutionService.ParentTransactionExecutionPackage> executionPackages) 
- 
prorateAmountDetailsprotected Map<String,javax.money.MonetaryAmount> prorateAmountDetails(List<DefaultTransactionExecutionService.ParentTransactionExecutionPackage> executionPackages, javax.money.MonetaryAmount requestDetailAmount, javax.money.MonetaryAmount requestTransactionAmount) 
- 
calculateProratedAmountprotected javax.money.MonetaryAmount calculateProratedAmount(javax.money.MonetaryAmount requestDetailTotal, javax.money.MonetaryAmount transactionAmount, javax.money.MonetaryAmount requestTransactionAmount) 
- 
getPaymentTransactionByIdprotected PaymentTransaction getPaymentTransactionById(@NonNull @NonNull Payment payment, @NonNull @NonNull String parentTransactionId) 
- 
getParentTransactionExecutionPackagesprotected 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 of- TransactionWithExecutableAmountsrepresenting parent transactions and their executable amounts
- totalToExecute- total amount to execute
- payment- the related- Paymentthat the transactions are acting against
- transactionService- the relevant- PaymentGatewayTransactionServicebased on the payment's- Payment.getGatewayType()
- contextInfo- context information surrounding multitenant state
- Returns:
- a list of ParentTransactionExecutionPackagesbased on the given parameters
 
- 
findFirstExecutableParentTransactionprotected TransactionWithExecutableAmount findFirstExecutableParentTransaction(List<TransactionWithExecutableAmount> parentTransactions, String paymentId) Finds the firstTransactionWithExecutableAmountwith amount available to execute.- Parameters:
- parentTransactions- a list of- TransactionWithExecutableAmountsto look from
- paymentId- the related- Payment.getId()that the parent transactions belong to
- Returns:
- the first TransactionWithExecutableAmountwith amount available to execute
- Throws:
- PaymentTransactionExecutionException- if no- TransactionWithExecutableAmountis found with available amount for execution
 
- 
executeAgainstParentTransactionprotected 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-date- Payment
- executionPackage- the- DefaultTransactionExecutionService.ParentTransactionExecutionPackagecontaining all the relevant data for transaction execution
- lockToken- 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- the- PaymentRequestto execute
- transactionService- the- PaymentGatewayTransactionServiceto execute the- PaymentRequestagainst
- executionRequest- the original- TransactionExecutionRequestthat the- PaymentRequestcreated from
- Returns:
- the PaymentResponsefrom the execution result
 
- 
executePaymentRequestprotected 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) 
- 
getTransactionExecutionFunctionprotected 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- the- TransactionExecutionRequestto get the- TransactionExecutionRequest.getTransactionType()from
- transactionService- the- PaymentGatewayTransactionServiceto find the execution method from
- Returns:
- a transaction execution Functionbased on the givenTransactionExecutionRequest.getTransactionType()and the givenPaymentGatewayTransactionService
- Throws:
- PaymentTransactionExecutionException- if the given- TransactionExecutionRequest.getTransactionType()does not match any methods in the given- PaymentGatewayTransactionService
 
- 
validateGatewayTransactionResponseprotected 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- The- GatewayTransactionResponseto be checked.
- payment- The related- Paymentthat the request will act against.
- contextInfo- Context information related to multitenancy.
- Throws:
- InvalidTransactionExecutionRequestException- if the- GatewayTransactionResponseis invalid.
 
- 
identifyTransactionResponseValidatorprotected 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
 
- 
identifyTransactionResponseServiceprotected 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
 
- 
buildAdditionalPaymentPropertiesHookpoint 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
- 
identifyTransactionServiceprotected com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService identifyTransactionService(@NonNull @NonNull Payment payment) Identifies the relevantPaymentGatewayTransactionServicebased on the payment'sPayment.getGatewayType()- Parameters:
- payment- The related- Paymentthat the request will act against.
- Returns:
- the identified PaymentGatewayTransactionService
 
- 
createPaymentTransactionprotected PaymentTransaction createPaymentTransaction(@NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull Payment payment, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) 
- 
createPaymentTransactionprotected PaymentTransaction createPaymentTransaction(@NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull Payment payment, @Nullable PaymentTransaction parentTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) 
- 
createPaymentTransactionprotected 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) 
- 
createPaymentTransactionprotected 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) 
- 
recordTransactionResponseprotected 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- the- PaymentTransactionto update and persist
- response- the- PaymentResponseto get the data from
- contextInfo- context information related to multitenancy
- Returns:
- updated and persisted PaymentTransaction
 
- 
updateTransactionBasedOnResponseprotected void updateTransactionBasedOnResponse(@NonNull @NonNull PaymentTransaction transaction, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Updates the givenPaymentTransactionbased on the givenPaymentResponse- Parameters:
- transaction- the- PaymentTransactionto update
- response- the- PaymentResponseto get the data from
 
- 
determineTransactionStatusprotected 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
 
- 
shouldRecordImpliedReverseAuthprotected boolean shouldRecordImpliedReverseAuth(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction captureTransaction, @NonNull @NonNull PaymentTransaction parentAuthTransaction) 
- 
recordImpliedReverseAuthprotected PaymentTransaction recordImpliedReverseAuth(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction captureTransaction, @NonNull @NonNull PaymentTransaction parentAuthTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) 
- 
createSavedPaymentMethodIfNeededprotected 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 saved
- paymentResponse- the- PaymentResponsefrom the transaction execution
- contextInfo- 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 transaction
- transaction- the transaction that was just executed
- response- the payment gateway's response to the transaction
- contextInfo- Context information related to multitenancy.
- Returns:
- the updated payment
 
- 
shouldArchivePaymentDueToFailedTransactionprotected 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 method
- transaction- 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 result
- response- the payment gateway's response to the transaction
- Returns:
- whether the PaymentResponse.getPaymentMethodProperties()should be stored on thePayment.
 
- 
recordPaymentMethodPropertiesFromResponseprotected 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 result
- response- the payment gateway's response to the transaction
- Returns:
- The updated Payment
 
- 
updateSavedPaymentBasedOnPaymentResponseprotected 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- the- Paymentthat potentially has a- SavedPaymentMethod
- response- the- PaymentResponsefrom the transaction execution
- contextInfo- context information related to multitenancy.
 
- 
isIndeterminateResultprotected 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
- 
recordTransactionResponseprotected 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 transaction
- response- the payment gateway's response to the executed transaction
- transactionType- the transaction type that was executed
- parentTransaction- the payment transaction that proceeded the transaction being processed
- contextInfo- Context information around sandbox and multitenant state.
- Returns:
- The recorded PaymentTransactionbased on the givenPaymentResponse
 
- 
getExisting3DSTransactionResultprotected 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
- 
getPaymentGatewayResourceProviderprotected com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider getPaymentGatewayResourceProvider()
- 
getPaymentTransactionService
- 
getTransactionResponseService
- 
getTransactionExecutionUtil
- 
getTypeFactoryprotected 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)