Interface TransactionResultService
- All Known Implementing Classes:
DefaultTransactionResultService
public interface TransactionResultService
The service to record subsequent payment transaction results. Responsible for building lookup
requests, recording the results from the gateway transaction response, and handling exceptions
from the lookup call to the gateway.
- Author:
- Marie Standeven (mstandeven)
-
Method Summary
Modifier and TypeMethodDescriptioncom.broadleafcommerce.paymentgateway.domain.TransactionLookupRequestbuildTransactionLookupRequest(@NonNull Payment payment, @NonNull PaymentTransaction paymentTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds the transaction details to pass to the payment gateway.getPayment(@NonNull PaymentTransaction pendingTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Fetches the payment that the pending transaction belongs to.handleRecordTransactionException(@NonNull Exception e, @NonNull String gatewayType, Payment payment, PaymentTransaction pendingTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Handles the exceptions thrown when recording transaction results.identifyChildTransaction(@NonNull Payment payment, @NonNull PaymentTransaction pendingTransaction) Identifies the child transaction of the pending transaction.identifyPendingTransactionByTransactionIdentifier(@NonNull com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier transactionIdentifier, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Identifies the transaction that is pending results from the gateway.lookupAndRecordRefundTransactionResult(String paymentId, String requestId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Lookup and record the transaction results for the Refund transaction identified by the providedpaymentIdandrequestId.lookupAndRecordSavedPaymentMethodTransactionResult(String savedPaymentMethodId, String requestId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Lookup and record the transaction results for the Authorize or AuthorizeAndCapture transaction identified by the providedsavedPaymentMethodIdandrequestId.recordChildTransactionResults(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull Payment payment, @NonNull PaymentTransaction pendingTransaction, @NonNull String managementStateReason, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Records the transaction results from the payment gateway.
-
Method Details
-
lookupAndRecordSavedPaymentMethodTransactionResult
TransactionExecutionResponse lookupAndRecordSavedPaymentMethodTransactionResult(String savedPaymentMethodId, String requestId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Lookup and record the transaction results for the Authorize or AuthorizeAndCapture transaction identified by the providedsavedPaymentMethodIdandrequestId. Note: This method is meant to be used in combination with transactions triggered fromSavedPaymentMethodTransactionExecutionEndpoint.executeAuthorize(String, SavedPaymentMethodTransactionExecutionRequest, ContextInfo)orSavedPaymentMethodTransactionExecutionEndpoint.executeAuthorizeAndCapture(String, SavedPaymentMethodTransactionExecutionRequest, ContextInfo). The relatedPaymentcan be uniquely identified by the combination of thesavedPaymentMethodIdandrequestId. ThePaymentTransactioncan then be identified within the payment's collection of transactions (Payment.getTransactions()) using the providedrequestId.- Parameters:
savedPaymentMethodId- The id of a saved payment method that was used to create thePayment& execute the transactionrequestId- The request id provided viaSavedPaymentMethodTransactionExecutionRequest.getRequestId()with the attempted Authorize or AuthorizeAndCapture transactioncontext- context information around the multi-tenant state- Returns:
- a
TransactionExecutionResponsedescribing the known state of the transaction. Note: This can contain transaction results, or communicate that transaction results are still not known. - Throws:
com.broadleafcommerce.data.tracking.core.exception.EntityMissingException- if the relatedPaymentorPaymentTransactioncannot be found based on the provided saved payment method id & request idcom.broadleafcommerce.paymentgateway.service.exception.TransactionNotFoundException- if the transaction cannot be foundcom.broadleafcommerce.paymentgateway.service.exception.FetchTransactionResultsException- if an exception is encountered while fetching transaction results- Since:
- PaymentTransactionServices 2.1.0, Release Train 2.3.0
-
lookupAndRecordRefundTransactionResult
TransactionExecutionResponse lookupAndRecordRefundTransactionResult(String paymentId, String requestId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Lookup and record the transaction results for the Refund transaction identified by the providedpaymentIdandrequestId.- Parameters:
paymentId- The id of thePaymentexecute the transactionrequestId- The request id provided viaTransactionExecutionRequest.getRequestId()with the attempted Refund transactioncontext- context information around the multi-tenant state- Returns:
- a
TransactionExecutionResponsedescribing the known state of the transaction. Note: This can contain transaction results, or communicate that transaction results are still not known. - Throws:
com.broadleafcommerce.data.tracking.core.exception.EntityMissingException- if the relatedPaymentorPaymentTransactioncannot be found based on the provided payment id & request idcom.broadleafcommerce.paymentgateway.service.exception.TransactionNotFoundException- if the transaction cannot be foundcom.broadleafcommerce.paymentgateway.service.exception.FetchTransactionResultsException- if an exception is encountered while fetching transaction results- Since:
- PaymentTransactionServices 2.1.0, Release Train 2.3.0
-
handleRecordTransactionException
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) Handles the exceptions thrown when recording transaction results.- Parameters:
e- the exception throwngatewayType- 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
TransactionExecutionResponsedescribing the resulting transaction andPaymentSummary - Throws:
UnsupportedOperationException- when looking up transaction results is not supported for the related payment gatewaycom.broadleafcommerce.paymentgateway.service.exception.InvalidGatewayConfigurationException- when the integration is not sufficiently configured to look up transaction resultscom.broadleafcommerce.paymentgateway.service.exception.InvalidFetchPaymentDetailsParamsException- when insufficient data is provided to look up transaction resultscom.broadleafcommerce.paymentgateway.service.exception.FetchTransactionResultsException- when an error occurred while looking up transaction resultscom.broadleafcommerce.paymentgateway.service.exception.TransactionNotFoundException- when a transaction cannot be found, based on the provided datacom.broadleafcommerce.paymentgateway.service.exception.TransactionResultsNotAvailableException- when the pending transaction results are not yet availablecom.broadleafcommerce.common.messaging.exception.ResourceLockException- when a payment lock cannot be obtained to record pending transaction results
-
getPayment
Payment getPayment(@NonNull @NonNull PaymentTransaction pendingTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Fetches the payment that the pending transaction belongs to. By default, this method returns the archived payment as well.- Parameters:
pendingTransaction- the transaction that is pending results from the gatewaycontext- the contextInfo for the request- Returns:
- the
Paymentthat this transaction belongs to
-
buildTransactionLookupRequest
com.broadleafcommerce.paymentgateway.domain.TransactionLookupRequest buildTransactionLookupRequest(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction paymentTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds the transaction details to pass to the payment gateway.- Parameters:
payment- thePaymentthat this transaction belongs topaymentTransaction- the transaction that is pending results from the gatewaycontextInfo- the contextInfo for the request- Returns:
- the request object including transaction-identifying data
-
identifyPendingTransactionByTransactionIdentifier
PaymentTransaction identifyPendingTransactionByTransactionIdentifier(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier transactionIdentifier, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Identifies the transaction that is pending results from the gateway.- Parameters:
transactionIdentifier- the identifier for the transactioncontextInfo- the contextInfo for the request- Returns:
- the
PaymentTransactionthat is pending results from the gateway
-
recordChildTransactionResults
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) Records the transaction results from the payment gateway.- Parameters:
paymentResponse- the payment gateway's response to the executed transactionpayment- thePaymentthat this transaction belongs topendingTransaction- the transaction that is pending results from the gatewaymanagementStateReason- the reason for the transaction managementState, i.e. "EXTERNAL_TRANSACTION"lockToken- the token that owns the payment lockcontext- the contextInfo for the request- Returns:
- the
TransactionExecutionResponsedescribing the resulting transaction andPaymentSummary
-
identifyChildTransaction
Optional<PaymentTransaction> identifyChildTransaction(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction pendingTransaction) Identifies the child transaction of the pending transaction.- Parameters:
payment- thePaymentthat this transaction belongs topendingTransaction- the transaction that is pending results from the gateway- Returns:
- the child transaction, if found
-