Class DefaultTransactionResultService

java.lang.Object
com.broadleafcommerce.paymenttransaction.service.DefaultTransactionResultService
All Implemented Interfaces:
TransactionResultService

public class DefaultTransactionResultService extends Object implements TransactionResultService
  • Constructor Details

  • Method Details

    • lookupAndRecordSavedPaymentMethodTransactionResult

      public TransactionExecutionResponse lookupAndRecordSavedPaymentMethodTransactionResult(@NonNull @NonNull String savedPaymentMethodId, @NonNull @NonNull String requestId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: TransactionResultService
      Lookup and record the transaction results for the Authorize or AuthorizeAndCapture transaction identified by the provided savedPaymentMethodId and requestId. Note: This method is meant to be used in combination with transactions triggered from SavedPaymentMethodTransactionExecutionEndpoint.executeAuthorize(String, SavedPaymentMethodTransactionExecutionRequest, ContextInfo) or SavedPaymentMethodTransactionExecutionEndpoint.executeAuthorizeAndCapture(String, SavedPaymentMethodTransactionExecutionRequest, ContextInfo). The related Payment can be uniquely identified by the combination of the savedPaymentMethodId and requestId. The PaymentTransaction can then be identified within the payment's collection of transactions (Payment.getTransactions()) using the provided requestId.
      Specified by:
      lookupAndRecordSavedPaymentMethodTransactionResult in interface TransactionResultService
      Parameters:
      savedPaymentMethodId - The id of a saved payment method that was used to create the Payment & execute the transaction
      requestId - The request id provided via SavedPaymentMethodTransactionExecutionRequest.getRequestId() with the attempted Authorize or AuthorizeAndCapture transaction
      context - context information around the multi-tenant state
      Returns:
      a TransactionExecutionResponse describing the known state of the transaction. Note: This can contain transaction results, or communicate that transaction results are still not known.
    • lookupAndRecordRefundTransactionResult

      public TransactionExecutionResponse lookupAndRecordRefundTransactionResult(@NonNull @NonNull String paymentId, @NonNull @NonNull String requestId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: TransactionResultService
      Lookup and record the transaction results for the Refund transaction identified by the provided paymentId and requestId.
      Specified by:
      lookupAndRecordRefundTransactionResult in interface TransactionResultService
      Parameters:
      paymentId - The id of the Payment execute the transaction
      requestId - The request id provided via TransactionExecutionRequest.getRequestId() with the attempted Refund transaction
      context - context information around the multi-tenant state
      Returns:
      a TransactionExecutionResponse describing the known state of the transaction. Note: This can contain transaction results, or communicate that transaction results are still not known.
    • handleRecordTransactionException

      public TransactionExecutionResponse handleRecordTransactionException(@NonNull @NonNull Exception e, @NonNull @NonNull String gatewayType, @Nullable Payment payment, @Nullable PaymentTransaction pendingTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: TransactionResultService
      Handles the exceptions thrown when recording transaction results.
      Specified by:
      handleRecordTransactionException in interface TransactionResultService
      Parameters:
      e - the exception thrown
      gatewayType - the gateway used to process this payment.
      payment - the payment being processed, if available.
      pendingTransaction - the transaction pending results, if available.
      context - the contextInfo for the request
      Returns:
      the TransactionExecutionResponse describing the resulting transaction and PaymentSummary
    • buildPendingTransactionNotFoundResponse

      protected TransactionExecutionResponse buildPendingTransactionNotFoundResponse(@NonNull @NonNull PaymentTransaction pendingTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    • getPayment

      public Payment getPayment(@NonNull @NonNull PaymentTransaction pendingTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: TransactionResultService
      Fetches the payment that the pending transaction belongs to. By default, this method returns the archived payment as well.
      Specified by:
      getPayment in interface TransactionResultService
      Parameters:
      pendingTransaction - the transaction that is pending results from the gateway
      context - the contextInfo for the request
      Returns:
      the Payment that this transaction belongs to
    • buildTransactionLookupRequest

      public com.broadleafcommerce.paymentgateway.domain.TransactionLookupRequest buildTransactionLookupRequest(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction paymentTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: TransactionResultService
      Builds the transaction details to pass to the payment gateway.
      Specified by:
      buildTransactionLookupRequest in interface TransactionResultService
      Parameters:
      payment - the Payment that this transaction belongs to
      paymentTransaction - the transaction that is pending results from the gateway
      contextInfo - the contextInfo for the request
      Returns:
      the request object including transaction-identifying data
    • identifyPendingTransactionByTransactionIdentifier

      public PaymentTransaction identifyPendingTransactionByTransactionIdentifier(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier transactionIdentifier, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: TransactionResultService
      Identifies the transaction that is pending results from the gateway.
      Specified by:
      identifyPendingTransactionByTransactionIdentifier in interface TransactionResultService
      Parameters:
      transactionIdentifier - the identifier for the transaction
      contextInfo - the contextInfo for the request
      Returns:
      the PaymentTransaction that is pending results from the gateway
    • recordChildTransactionResults

      public TransactionExecutionResponse recordChildTransactionResults(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction pendingTransaction, @NonNull @NonNull String managementStateReason, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: TransactionResultService
      Records the transaction results from the payment gateway.
      Specified by:
      recordChildTransactionResults in interface TransactionResultService
      Parameters:
      paymentResponse - the payment gateway's response to the executed transaction
      payment - the Payment that this transaction belongs to
      pendingTransaction - the transaction that is pending results from the gateway
      managementStateReason - the reason for the transaction managementState, i.e. "EXTERNAL_TRANSACTION"
      lockToken - the token that owns the payment lock
      context - the contextInfo for the request
      Returns:
      the TransactionExecutionResponse describing the resulting transaction and PaymentSummary
    • identifyChildTransaction

      public Optional<PaymentTransaction> identifyChildTransaction(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction transactionRequiringExternal)
      Description copied from interface: TransactionResultService
      Identifies the child transaction of the pending transaction.
      Specified by:
      identifyChildTransaction in interface TransactionResultService
      Parameters:
      payment - the Payment that this transaction belongs to
      transactionRequiringExternal - the transaction that is pending results from the gateway
      Returns:
      the child transaction, if found
    • buildContextInfoFromTransaction

      protected com.broadleafcommerce.data.tracking.core.context.ContextInfo buildContextInfoFromTransaction(@NonNull @NonNull PaymentTransaction transaction)
    • logIfPaymentArchived

      protected void logIfPaymentArchived(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction transaction)
    • transactionResultsAreAlreadyKnown

      protected boolean transactionResultsAreAlreadyKnown(@NotNull @NotNull PaymentTransaction transaction)
    • recordTransactionResults

      protected TransactionExecutionResponse recordTransactionResults(@NonNull @NonNull PaymentTransaction paymentTransaction, @NonNull @NonNull Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • validateTransactionResults

      protected void validateTransactionResults(@NonNull @NonNull TransactionExecutionResponse transactionResponse, @NonNull @NonNull PaymentTransaction transaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • recordTransactionRequestNotReceivedByGateway

      protected TransactionExecutionResponse recordTransactionRequestNotReceivedByGateway(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction transaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    • 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
    • getPaymentTransactionService

      protected PaymentTransactionService<PaymentTransaction> getPaymentTransactionService()
    • getTransactionExecutionUtil

      protected TransactionExecutionUtil getTransactionExecutionUtil()
    • getPaymentService

      protected PaymentService<Payment> getPaymentService()
    • getPaymentLockService

      protected PaymentLockService<Payment> getPaymentLockService()
    • getTransactionExecutionService

      protected TransactionExecutionService getTransactionExecutionService()
    • setPaymentGatewayResourceProvider

      @Autowired public void setPaymentGatewayResourceProvider(com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider paymentGatewayResourceProvider)
    • getPaymentGatewayResourceProvider

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

      protected SavedPaymentMethodManagementService getSavedPaymentMethodManagementService()
    • setSavedPaymentMethodManagementService

      @Autowired public void setSavedPaymentMethodManagementService(SavedPaymentMethodManagementService savedPaymentMethodManagementService)
    • getTypeFactory

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