Interface PaymentTransactionService<T extends PaymentTransaction>
- All Superinterfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<T>
,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<T>
- All Known Implementing Classes:
DefaultPaymentTransactionService
public interface PaymentTransactionService<T extends PaymentTransaction>
extends com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<T>
Service responsible for the creation of PaymentTransactions & the recording of
PaymentResponse
results on the PaymentTransaction- Author:
- Chris Kittrell (ckittrell)
-
Method Summary
Modifier and TypeMethodDescriptionbuildChildPaymentTransactionForResponse
(Payment payment, PaymentTransaction parentTransaction, com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) Creates the new child payment transaction for the specified parent transaction based on the payment response.claimTransactionsForRequest
(Payment payment, String requestId, String transactionType, boolean resetTransactionReversalState, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates thePaymentTransaction.getRequestId()
with the new value, stores the previous value toPaymentTransaction.getPreviousRequestIds()
, clearsPaymentTransaction.getManagementState()
andPaymentTransaction.getManagementStateReason()
.readAllByContextIdInAndManagementStateIn
(List<String> contextIds, List<String> managementStates, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the transactions with the specified ids and management states.org.springframework.data.domain.Page<T>
readAllByDateRecordedBeforeAndManagementStateIsNotIn
(Instant date, List<String> managementStates, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the transactions with the recorded date before the specified time and management statuses not in the specified list.org.springframework.data.domain.Page<T>
readAllByManagementStateIn
(List<String> managementStates, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the transactions with the specified management states.org.springframework.data.domain.Page<T>
readAllByManagementStateInAndStatusIn
(List<String> managementStates, List<String> transactionStatuses, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the transactions with the specified management states and transaction statuses.readByGatewayTransactionId
(String gatewayTransactionId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns transaction identified by the gateway transaction id.readByGatewayTransactionIdAndTenantId
(String gatewayTransactionId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the transaction identified by the gateway transaction id, ignoring other context filtering like archival status.readByTransactionReferenceId
(String transactionReferenceId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the transactions with the specified transaction reference id.readByTransactionReferenceIdAndTenantId
(String transactionReferenceId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the transaction with the specified transaction reference id, ignoring other context filtering like archival status.org.springframework.data.domain.Page<T>
readTransactionsToReverse
(Duration reversalCandidateTtl, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads the payment transactions that are eligible for reversal.recordTransactionResponse
(T transaction, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, boolean saveResult, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the givenPaymentTransaction
based on the givenPaymentResponse
and persists thePaymentTransaction
.default T
recordTransactionResponse
(T transaction, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the givenPaymentTransaction
based on the givenPaymentResponse
and persists thePaymentTransaction
.updateTransactionBasedOnResponse
(T transaction, com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Updates the givenPaymentTransaction
based on the givenPaymentResponse
.Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService
create, createAll, createAllAllowingPartialSuccess, delete, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSort
Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService
readAll, readAll, readAll, readAll
-
Method Details
-
readAllByContextIdInAndManagementStateIn
List<T> readAllByContextIdInAndManagementStateIn(List<String> contextIds, List<String> managementStates, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the transactions with the specified ids and management states.- Parameters:
contextIds
- the ids of the transactionsmanagementStates
- the management states of the transactionscontext
- Request context information around sandbox and multitenant state- Returns:
- the transactions with the specified ids and management states
-
readAllByManagementStateIn
org.springframework.data.domain.Page<T> readAllByManagementStateIn(List<String> managementStates, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the transactions with the specified management states.- Parameters:
managementStates
- the management states of the transactionspage
- The requested page of results from the database.context
- Request context information around sandbox and multitenant state- Returns:
- the transactions with the specified management states
-
readAllByManagementStateInAndStatusIn
org.springframework.data.domain.Page<T> readAllByManagementStateInAndStatusIn(List<String> managementStates, List<String> transactionStatuses, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the transactions with the specified management states and transaction statuses.- Parameters:
managementStates
- the management states of the transactionstransactionStatuses
- the statuses of the transactionspage
- The requested page of results from the database.context
- Request context information around sandbox and multitenant state- Returns:
- the transactions with the specified management states and transaction statuses
-
readAllByDateRecordedBeforeAndManagementStateIsNotIn
org.springframework.data.domain.Page<T> readAllByDateRecordedBeforeAndManagementStateIsNotIn(Instant date, List<String> managementStates, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the transactions with the recorded date before the specified time and management statuses not in the specified list.- Parameters:
date
- the date until which the transaction was recordedmanagementStates
- the management states to avoidpage
- The requested page of results from the database.context
- Request context information around sandbox and multitenant state- Returns:
- the transactions with the specified management states
-
readByTransactionReferenceId
T readByTransactionReferenceId(String transactionReferenceId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the transactions with the specified transaction reference id.- Parameters:
transactionReferenceId
- the transaction id known by the payment gatewaycontext
- Request context information around sandbox and multitenant state- Returns:
- the transactions with the specified transaction reference id
-
readByTransactionReferenceIdAndTenantId
T readByTransactionReferenceIdAndTenantId(String transactionReferenceId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the transaction with the specified transaction reference id, ignoring other context filtering like archival status.- Parameters:
transactionReferenceId
- the transaction id known by the payment gatewaycontext
- Request context information around sandbox and multitenant state- Returns:
- the transaction with the specified transaction reference id
-
readByGatewayTransactionId
T readByGatewayTransactionId(String gatewayTransactionId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns transaction identified by the gateway transaction id.- Parameters:
gatewayTransactionId
- The id of the payment gateway's transaction representation.context
- Request context information around sandbox and multitenant state- Returns:
- Transaction with the specified gateway transaction id.
-
readByGatewayTransactionIdAndTenantId
T readByGatewayTransactionIdAndTenantId(String gatewayTransactionId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the transaction identified by the gateway transaction id, ignoring other context filtering like archival status.- Parameters:
gatewayTransactionId
- The id of the payment gateway's transaction representation.context
- Request context information around sandbox and multitenant state- Returns:
- Transaction with the specified gateway transaction id.
-
recordTransactionResponse
default T recordTransactionResponse(@NonNull T transaction, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the givenPaymentTransaction
based on the givenPaymentResponse
and persists thePaymentTransaction
.- Parameters:
transaction
- thePaymentTransaction
to update and persistresponse
- thePaymentResponse
to get the data fromcontextInfo
- context information related to multitenancy- Returns:
- updated and persisted
PaymentTransaction
-
recordTransactionResponse
T recordTransactionResponse(@NonNull T transaction, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, boolean saveResult, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the givenPaymentTransaction
based on the givenPaymentResponse
and persists thePaymentTransaction
.- Parameters:
transaction
- thePaymentTransaction
to update and persistresponse
- thePaymentResponse
to get the data fromsaveResult
- save updated transaction if truecontextInfo
- context information related to multitenancy- Returns:
- updated and persisted
PaymentTransaction
-
readTransactionsToReverse
org.springframework.data.domain.Page<T> readTransactionsToReverse(Duration reversalCandidateTtl, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads the payment transactions that are eligible for reversal. By default, this method returns the transaction withDefaultTransactionManagementStates.REVERSAL_CANDIDATE
management state,DefaultTransactionStatuses.SUCCESS
status and that have not been updated within a specified duration.- Parameters:
reversalCandidateTtl
- the amount of time the payment transactions have not been updated and can be reversedpage
- The requested page of results from the databasecontextInfo
- context information related to multitenancy- Returns:
- the payment transactions that are eligible for reversal
- See Also:
-
claimTransactionsForRequest
Payment claimTransactionsForRequest(Payment payment, String requestId, String transactionType, boolean resetTransactionReversalState, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates thePaymentTransaction.getRequestId()
with the new value, stores the previous value toPaymentTransaction.getPreviousRequestIds()
, clearsPaymentTransaction.getManagementState()
andPaymentTransaction.getManagementStateReason()
.- Parameters:
payment
- thePayment
instancerequestId
- id used to represent the request that produced this transaction e.g during checkouttransactionType
- the transaction type to changeresetTransactionReversalState
- reset or not the state of the transaction reversallockToken
- token granted to resource that owns the payment lockcontextInfo
- context information related to multitenancy- Returns:
- The up-to-date
Payment
record
-
buildChildPaymentTransactionForResponse
T buildChildPaymentTransactionForResponse(Payment payment, PaymentTransaction parentTransaction, com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) Creates the new child payment transaction for the specified parent transaction based on the payment response. By default this method doesn't store the created transaction.- Parameters:
payment
- thePayment
instanceparentTransaction
- the parent transactionpaymentResponse
- thePaymentResponse
to get the data from- Returns:
- the new child
PaymentTransaction
for the specified payment and parent transaction
-
updateTransactionBasedOnResponse
T updateTransactionBasedOnResponse(T transaction, com.broadleafcommerce.paymentgateway.domain.PaymentResponse response) Updates the givenPaymentTransaction
based on the givenPaymentResponse
.- Parameters:
transaction
- thePaymentTransaction
to updateresponse
- thePaymentResponse
to update the transaction with- Returns:
- the updated
PaymentTransaction
based on the givenPaymentResponse
-