Class DefaultTransactionExecutionService

java.lang.Object
com.broadleafcommerce.paymenttransaction.service.DefaultTransactionExecutionService
All Implemented Interfaces:
TransactionExecutionService

public class DefaultTransactionExecutionService extends Object implements TransactionExecutionService
  • Constructor Details

  • Method Details

    • authorize

      public TransactionExecutionResponse authorize(@NonNull @NonNull TransactionExecutionRequest request, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: TransactionExecutionService
      Communicates with the relevant payment gateway to execute an DefaultTransactionTypes.AUTHORIZE transaction.
      Specified by:
      authorize in interface TransactionExecutionService
      Parameters:
      request - The TransactionExecutionRequest describing the desired details of the transaction.
      lockToken - Token granted to resource that owns the payment lock.
      Returns:
      The TransactionExecutionDetail describing the resulting transaction and PaymentSummary.
    • authorizeAndCapture

      public TransactionExecutionResponse authorizeAndCapture(@NonNull @NonNull TransactionExecutionRequest request, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: TransactionExecutionService
      Communicates with the relevant payment gateway to execute an DefaultTransactionTypes.AUTHORIZE_AND_CAPTURE transaction.
      Specified by:
      authorizeAndCapture in interface TransactionExecutionService
      Parameters:
      request - The TransactionExecutionRequest describing the desired details of the transaction.
      lockToken - Token granted to resource that owns the payment lock.
      Returns:
      The TransactionExecutionDetail describing the resulting transaction and PaymentSummary.
    • capture

      public TransactionExecutionResponse capture(@NonNull @NonNull TransactionExecutionRequest request, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: TransactionExecutionService
      Communicates with the relevant payment gateway to execute a DefaultTransactionTypes.CAPTURE transaction.
      Specified by:
      capture in interface TransactionExecutionService
      Parameters:
      request - The TransactionExecutionRequest describing the desired details of the transaction.
      lockToken - Token granted to resource that owns the payment lock.
      Returns:
      The TransactionExecutionDetail describing the resulting transaction and PaymentSummary.
    • reverseAuthorize

      public TransactionExecutionResponse reverseAuthorize(@NonNull @NonNull TransactionExecutionRequest request, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: TransactionExecutionService
      Communicates with the relevant payment gateway to execute a DefaultTransactionTypes.REVERSE_AUTH transaction.
      Specified by:
      reverseAuthorize in interface TransactionExecutionService
      Parameters:
      request - The TransactionExecutionRequest describing the desired details of the transaction.
      lockToken - Token granted to resource that owns the payment lock.
      Returns:
      The TransactionExecutionDetail describing the resulting transaction and PaymentSummary.
    • refund

      public TransactionExecutionResponse refund(@NonNull @NonNull TransactionExecutionRequest request, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: TransactionExecutionService
      Communicates with the relevant payment gateway to execute a DefaultTransactionTypes.REFUND transaction.
      Specified by:
      refund in interface TransactionExecutionService
      Parameters:
      request - The TransactionExecutionRequest describing the desired details of the transaction.
      lockToken - Token granted to resource that owns the payment lock.
      Returns:
      The TransactionExecutionDetail describing the resulting transaction and PaymentSummary.
    • detachedCredit

      public TransactionExecutionResponse detachedCredit(@NonNull @NonNull TransactionExecutionRequest request, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: TransactionExecutionService
      Communicates with the relevant payment gateway to execute a DefaultTransactionTypes.DETACHED_CREDIT transaction.

      If TransactionExecutionRequest.getParentTransactionId() is provided, then we'll consider it to be acting as a refund. In this case, the parent transaction should have DefaultTransactionTypes.CAPTURE or DefaultTransactionTypes.AUTHORIZE_AND_CAPTURE type, and TransactionExecutionRequest.getTransactionAmount() must be less than or equal to the parent transaction's amount.

      Specified by:
      detachedCredit in interface TransactionExecutionService
      Parameters:
      request - The TransactionExecutionRequest describing the desired details of the transaction.
      lockToken - Token granted to resource that owns the payment lock.
      Returns:
      The TransactionExecutionDetail describing the resulting transaction and PaymentSummary.
    • recordGatewayTransactionResults

      public TransactionExecutionResponse recordGatewayTransactionResults(@NonNull @NonNull String paymentId, @NonNull @NonNull Map<String,Object> transactionResults, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: TransactionExecutionService
      Records transaction results that are processed by the gateway outside the checkout workflow.
      Specified by:
      recordGatewayTransactionResults in 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 TransactionExecutionResponse describing the resulting transaction and PaymentSummary.
    • 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 a GatewayTransactionResponse from the payment and including the gateway transaction results.
      Parameters:
      payment - the Payment that 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 GatewayTransactionResponse based on the payment and including the gateway transaction results
    • buildPaymentResponseFromTransactionResults

      protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse buildPaymentResponseFromTransactionResults(@NonNull @NonNull Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.GatewayTransactionResponse gatewayTransactionResponse, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Builds a PaymentResponse from the gateway transaction results.
      Parameters:
      payment - the Payment that this transaction belongs to
      gatewayTransactionResponse - the payment gateway's response to the transaction
      context - context information related to multitenancy.
      Returns:
      the PaymentResponse based on the gateway transaction results
    • updatePaymentBasedOnTransactionResult

      @Nullable public Payment updatePaymentBasedOnTransactionResult(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction transaction, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Based on the results of the payment gateway authorize transaction, update the Payment and SavedPaymentMethod.
      Specified by:
      updatePaymentBasedOnTransactionResult in 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
    • 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 - The TransactionExecutionRequest describing 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
    • 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 given TransactionExecutionRequest against parent transactions.

      This is used for TransactionTypes that require proceeding transactions. For example, DefaultTransactionTypes.REFUND requires a proceeding DefaultTransactionTypes.CAPTURE, this method looks for all the capture transactions and execute refund against them based on the given TransactionExecutionRequest.

      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 TransactionExecutionRequest to execute
      lockToken - Token granted to resource that owns the payment lock.
      contextInfo - context information surrounding multitenant state
      Returns:
      a TransactionExecutionResponse representing the execution result of the given TransactionExecutionRequest
    • hasTransactionAmountDetails

      protected boolean hasTransactionAmountDetails(TransactionExecutionRequest request)
    • prorateTransactionAmountDetails

    • prorateAmountDetails

      protected Map<String,javax.money.MonetaryAmount> prorateAmountDetails(List<DefaultTransactionExecutionService.ParentTransactionExecutionPackage> executionPackages, javax.money.MonetaryAmount requestDetailAmount, javax.money.MonetaryAmount requestTransactionAmount)
    • calculateProratedAmount

      protected javax.money.MonetaryAmount calculateProratedAmount(javax.money.MonetaryAmount requestDetailTotal, javax.money.MonetaryAmount transactionAmount, javax.money.MonetaryAmount requestTransactionAmount)
    • getPaymentTransactionById

      protected PaymentTransaction getPaymentTransactionById(@NonNull @NonNull Payment payment, @NonNull @NonNull String parentTransactionId)
    • getParentTransactionExecutionPackages

      protected List<DefaultTransactionExecutionService.ParentTransactionExecutionPackage> getParentTransactionExecutionPackages(TransactionExecutionRequest request, List<TransactionWithExecutableAmount> parentTransactions, javax.money.MonetaryAmount totalToExecute, Payment payment, com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService transactionService, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Gets a list of ParentTransactionExecutionPackages based on the given parameters.
      Parameters:
      parentTransactions - a list of TransactionWithExecutableAmounts representing parent transactions and their executable amounts
      totalToExecute - total amount to execute
      payment - the related Payment that the transactions are acting against
      transactionService - the relevant PaymentGatewayTransactionService based on the payment's Payment.getGatewayType()
      contextInfo - context information surrounding multitenant state
      Returns:
      a list of ParentTransactionExecutionPackages based on the given parameters
    • findFirstExecutableParentTransaction

      protected TransactionWithExecutableAmount findFirstExecutableParentTransaction(List<TransactionWithExecutableAmount> parentTransactions, String paymentId)
      Finds the first TransactionWithExecutableAmount with amount available to execute.
      Parameters:
      parentTransactions - a list of TransactionWithExecutableAmounts to look from
      paymentId - the related Payment.getId() that the parent transactions belong to
      Returns:
      the first TransactionWithExecutableAmount with amount available to execute
      Throws:
      PaymentTransactionExecutionException - if no TransactionWithExecutableAmount is found with available amount for execution
    • executeAgainstParentTransaction

      protected org.apache.commons.lang3.tuple.Pair<Payment,TransactionExecutionDetail> executeAgainstParentTransaction(@NonNull @NonNull Payment payment, @NonNull @NonNull DefaultTransactionExecutionService.ParentTransactionExecutionPackage executionPackage, @Nullable String lockToken)
      Parameters:
      payment - the most up-to-date Payment
      executionPackage - the DefaultTransactionExecutionService.ParentTransactionExecutionPackage containing all the relevant data for transaction execution
      lockToken - Token granted to resource that owns the payment lock.
      Returns:
      the pair of TransactionExecutionDetail representing the execution result of the given DefaultTransactionExecutionService.ParentTransactionExecutionPackage and updated Payment
    • 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 given PaymentRequest based on the given TransactionExecutionRequest against the given PaymentGatewayTransactionService.
      Parameters:
      paymentRequest - the PaymentRequest to execute
      transactionService - the PaymentGatewayTransactionService to execute the PaymentRequest against
      executionRequest - the original TransactionExecutionRequest that the PaymentRequest created from
      Returns:
      the PaymentResponse from the execution result
    • executePaymentRequest

      protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse executePaymentRequest(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest, @NonNull @NonNull com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService transactionService, @NonNull @NonNull TransactionExecutionRequest executionRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getTransactionExecutionFunction

      protected Function<com.broadleafcommerce.paymentgateway.domain.PaymentRequest,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> getTransactionExecutionFunction(@NonNull @NonNull TransactionExecutionRequest request, com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService transactionService)
      Gets a transaction execution Function based on the given TransactionExecutionRequest.getTransactionType() and the given PaymentGatewayTransactionService.
      Parameters:
      request - the TransactionExecutionRequest to get the TransactionExecutionRequest.getTransactionType() from
      transactionService - the PaymentGatewayTransactionService to find the execution method from
      Returns:
      a transaction execution Function based on the given TransactionExecutionRequest.getTransactionType() and the given PaymentGatewayTransactionService
      Throws:
      PaymentTransactionExecutionException - if the given TransactionExecutionRequest.getTransactionType() does not match any methods in the given PaymentGatewayTransactionService
    • 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 the GatewayTransactionResponse can validly be added to the payment.
      Parameters:
      transactionResponse - The GatewayTransactionResponse to be checked.
      payment - The related Payment that the request will act against.
      contextInfo - Context information related to multitenancy.
      Throws:
      InvalidTransactionExecutionRequestException - if the GatewayTransactionResponse is invalid.
    • identifyTransactionResponseValidator

      protected com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionResponseValidator identifyTransactionResponseValidator(@NonNull @NonNull Payment payment)
      Identifies the relevant PaymentGatewayTransactionResponseValidator based on the payment's Payment.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 relevant PaymentGatewayTransactionResponseService based on the payment's Payment.getGatewayType()
      Parameters:
      payment - the payment object that contains a reference to the required transaction service
      Returns:
      the identified PaymentGatewayTransactionResponseService
    • buildAdditionalPaymentProperties

      protected Map<String,Object> buildAdditionalPaymentProperties(Payment payment)
      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

      @Nullable protected PaymentTransaction identifyParentTransactionIfExists(com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService transactionService, Map<String,Object> transactionResults, Map<String,Object> additionalPaymentProperties, Payment payment)
    • identifyTransactionService

      protected com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService identifyTransactionService(@NonNull @NonNull Payment payment)
      Identifies the relevant PaymentGatewayTransactionService based on the payment's Payment.getGatewayType()
      Parameters:
      payment - The related Payment that the request will act against.
      Returns:
      the identified PaymentGatewayTransactionService
    • createPaymentTransaction

      protected PaymentTransaction createPaymentTransaction(@NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull Payment payment, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • createPaymentTransaction

      protected PaymentTransaction createPaymentTransaction(@NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull Payment payment, @Nullable PaymentTransaction parentTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • createPaymentTransaction

      protected PaymentTransaction createPaymentTransaction(@NonNull @NonNull javax.money.MonetaryAmount transactionAmount, @NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull Payment payment, @Nullable PaymentTransaction parentTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • createPaymentTransaction

      protected PaymentTransaction createPaymentTransaction(@NonNull @NonNull TransactionAmountDetails transactionAmountDetails, @NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull Payment payment, @Nullable PaymentTransaction parentTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • recordTransactionResponse

      protected PaymentTransaction recordTransactionResponse(@NonNull @NonNull PaymentTransaction transaction, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Updates the given PaymentTransaction based on the given PaymentResponse and persists the PaymentTransaction.
      Parameters:
      transaction - the PaymentTransaction to update and persist
      response - the PaymentResponse to get the data from
      contextInfo - 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 given PaymentTransaction based on the given PaymentResponse
      Parameters:
      transaction - the PaymentTransaction to update
      response - the PaymentResponse to get the data from
    • determineTransactionStatus

      protected String determineTransactionStatus(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response)
      Determines the new status of the PaymentTransaction based on the contents of the PaymentResponse
      Parameters:
      response - the payment gateway's response to the executed transaction
      Returns:
      the new status of the PaymentTransaction based on the contents of the PaymentResponse
    • 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 of SavedPaymentMethodManagementService from the given Payment if necessary.
      Parameters:
      payment - the payment that should be saved
      paymentResponse - the PaymentResponse from 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
    • shouldArchivePaymentDueToFailedTransaction

      protected boolean shouldArchivePaymentDueToFailedTransaction(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction transaction)
      Determines whether or not the Payment should be archived due to the failed transaction that is described by the provided PaymentResponse. 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 used
      Decides whether the PaymentResponse.getPaymentMethodProperties() should be stored on the Payment. 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 the Payment.
    • recordPaymentMethodPropertiesFromResponse

      protected Payment recordPaymentMethodPropertiesFromResponse(@NonNull @NonNull Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response)
      Stores the PaymentResponse.getPaymentMethodProperties() on the Payment and sets Payment.isSingleUsePaymentMethod() to false if PaymentResponse.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
    • 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 the SavedPaymentMethod for the given Payment.
      Parameters:
      payment - the Payment that potentially has a SavedPaymentMethod
      response - the PaymentResponse from the transaction execution
      contextInfo - 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

      protected PaymentRef buildPaymentRef(Payment payment)
    • 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 the Payment and PaymentResponse.
      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 PaymentTransaction based on the given PaymentResponse
    • 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

      protected PaymentService<Payment> getPaymentService()
    • getPaymentManagementService

      protected PaymentManagementService<Payment> getPaymentManagementService()
    • getRequestValidator

      protected TransactionExecutionRequestValidator getRequestValidator()
    • getPaymentLockService

      protected PaymentLockService<Payment> getPaymentLockService()
    • getPaymentRequestService

      protected PaymentRequestService getPaymentRequestService()
    • getPaymentGatewayResourceProvider

      protected com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider getPaymentGatewayResourceProvider()
    • getPaymentTransactionService

      protected PaymentTransactionService<PaymentTransaction> getPaymentTransactionService()
    • getTransactionResponseService

      protected TransactionResponseService getTransactionResponseService()
    • getTransactionExecutionUtil

      protected TransactionExecutionUtil getTransactionExecutionUtil()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • getSavedPaymentMethodManagementService

      protected SavedPaymentMethodManagementService getSavedPaymentMethodManagementService()
    • setSavedPaymentMethodManagementService

      @Autowired public void setSavedPaymentMethodManagementService(SavedPaymentMethodManagementService savedPaymentMethodManagementService)
    • getMonetaryAmountRoundingHelper

      protected MonetaryAmountRoundingHelper getMonetaryAmountRoundingHelper()
    • setMonetaryAmountRoundingHelper

      @Autowired public void setMonetaryAmountRoundingHelper(MonetaryAmountRoundingHelper monetaryAmountRoundingHelper)
    • getSavedPaymentMethodService

      @Nullable protected SavedPaymentMethodService<SavedPaymentMethod> getSavedPaymentMethodService()
    • setSavedPaymentMethodService

      @Autowired(required=false) public void setSavedPaymentMethodService(@Nullable SavedPaymentMethodService<SavedPaymentMethod> savedPaymentMethodService)
    • getCustomerNotificationService

      protected PaymentCustomerNotificationService getCustomerNotificationService()
    • setCustomerNotificationService

      @Autowired public void setCustomerNotificationService(PaymentCustomerNotificationService customerNotificationService)