Interface PaymentProvider<P extends PaymentSummary>
- All Known Implementing Classes:
ExternalPaymentProvider
public interface PaymentProvider<P extends PaymentSummary>
Provider for interfacing with a Payment Management system for operations around payment related
entities. Typically utilizes
WebClient
to make requests to an external REST API.- Author:
- Dima Myroniuk (dmyroniuk), Sunny Yu
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
archivePayment
(String paymentId, Integer version, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Archives the payment based on the provided id and version.void
archivePayment
(String paymentId, Integer version, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Archives the payment based on the provided id and version.blockCustomerMutabilityForPaymentFinalization
(String cartId, Map<String, String> paymentLockTokens, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Blocks customer mutability for the cart's payments while payment finalization is completed.blockCustomerMutabilityForPayments
(String ownerId, Map<String, String> paymentLockTokens, boolean markTransactionsIneligibleForAutoReversal, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Blocks customer mutability for the cart's payments.claimTransactionsForRequest
(ClaimCheckoutTransactionsRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the payment transaction request id with the new value, stores the previous value, clears transaction management state and management state reason.default void
claimTransactionsForRequest
(String paymentId, String requestId, String transactionType, boolean resetTransactionReversalState, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated, for removal: This API element is subject to removal in a future version.finalizePaymentsForCheckout
(String ownerId, Map<String, String> paymentLockTokens, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) The PaymentTransactionServices internally prepares and finalizes the payments for checkout.lockAndRetrieveCartPayments
(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Same functionality aslockCartPayments(Cart, ContextInfo)
but this method also includes thePaymentSummaries
in the response.lockCartPayments
(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Locks the cart's payments to ensure that all of the work done within theCheckoutWorkflow
and checkout process in general is consistently interacting with payments that will not change.default PaymentSummary
patchPayment
(@NonNull UpdatePaymentRequest updatePaymentRequest, @NonNull Integer version, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Updates the payment based on the providedUpdatePaymentRequest
.patchPayment
(UpdatePaymentRequest updatePaymentRequest, Integer version, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Updates the payment based on the providedUpdatePaymentRequest
.readAllByOwnerTypeAndOwnerId
(String ownerType, String ownerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a list ofPaymentSummaries
that belong to the given owner type and owner id.readByCartId
(@NonNull String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a list ofPaymentSummaries
that belong to the givenCart.getId()
.removeCustomerMutabilityBlockForPaymentFinalization
(String cartId, Map<String, String> paymentLockTokens, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Unblocks customer mutability for the cart's payments.default UpdatePaymentsResponse
transferPaymentsToCSR
(String ownerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) transferPaymentsToCSR
(String ownerId, Map<String, String> paymentLockTokens, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) The PaymentTransactionServices internally prepares and transfers the payments to the CSR user.default UpdatePaymentsResponse
transferPaymentsToCustomer
(String ownerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) transferPaymentsToCustomer
(String ownerId, Map<String, String> paymentLockTokens, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) The PaymentTransactionServices internally prepares and transfers the payments to the customer user.void
unlockCartPayments
(Collection<String> lockTokens, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Unlocks the cart's payments, based on the lock tokens that were previously obtained vialockCartPayments(Cart, ContextInfo)
.
-
Method Details
-
readByCartId
default List<P> readByCartId(@NonNull @NonNull String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a list ofPaymentSummaries
that belong to the givenCart.getId()
.- Parameters:
cartId
- theCart.getId()
of thePaymentSummaries
to retrievecontextInfo
- context information around sandbox and multitenant state.- Returns:
- a list of
PaymentSummaries
that belong to the givenCart.getId()
-
readAllByOwnerTypeAndOwnerId
List<P> readAllByOwnerTypeAndOwnerId(String ownerType, String ownerId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a list ofPaymentSummaries
that belong to the given owner type and owner id.- Parameters:
ownerType
- the owner type of thePaymentSummaries
to retrieveownerId
- the owner id of thePaymentSummaries
to retrievecontextInfo
- context information around sandbox and multitenant state.- Returns:
- a list of
PaymentSummaries
based on the given owner type and owner id
-
patchPayment
default PaymentSummary patchPayment(@NonNull @NonNull UpdatePaymentRequest updatePaymentRequest, @NonNull @NonNull Integer version, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Updates the payment based on the providedUpdatePaymentRequest
. This method can be used to partially update the payment. To do so provide only the fields you would like to update. The default implementation archives the payment ifUpdatePaymentRequest.getAmount()
is equal to zero.- Parameters:
updatePaymentRequest
- the request payload used to update the paymentversion
- the payment versioncontext
- Context information related to multitenancy- Returns:
- the updated payment summary.
-
patchPayment
PaymentSummary patchPayment(UpdatePaymentRequest updatePaymentRequest, Integer version, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Updates the payment based on the providedUpdatePaymentRequest
. This method can be used to partially update the payment. To do so provide only the fields you would like to update. The default implementation archives the payment ifUpdatePaymentRequest.getAmount()
is equal to zero.- Parameters:
updatePaymentRequest
- the request payload used to update the paymentversion
- the payment versionlockToken
- the token that owns the payment lockcontext
- Context information related to multitenancy- Returns:
- the updated payment summary.
-
archivePayment
default void archivePayment(String paymentId, Integer version, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Archives the payment based on the provided id and version.- Parameters:
paymentId
- the context id of the paymentversion
- the payment versioncontext
- context information related to multitenancy
-
archivePayment
void archivePayment(String paymentId, Integer version, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Archives the payment based on the provided id and version.- Parameters:
paymentId
- the context id of the paymentversion
- the payment versionlockToken
- Token that can be used to unlock the cart's paymentcontext
- context information related to multitenancy
-
lockCartPayments
Map<String,String> lockCartPayments(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Locks the cart's payments to ensure that all of the work done within theCheckoutWorkflow
and checkout process in general is consistently interacting with payments that will not change. With these locks in place, only this executing process will have access to modify the payments, until the lock TTL expires. Note: make sure that the checkout process can sufficiently be contained within the payment lock TTL. This can be configured in PaymentTransactionServices.- Parameters:
cart
- theCart
whose payments are to be locked.contextInfo
- context information around sandbox and multitenant state.- Returns:
- A map of payment id to lock token.
- Throws:
PaymentLockException
- if a lock could not be obtained.
-
lockAndRetrieveCartPayments
LockPaymentsResponse lockAndRetrieveCartPayments(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Same functionality aslockCartPayments(Cart, ContextInfo)
but this method also includes thePaymentSummaries
in the response.This is useful to reduce the amount of network calls.
- Parameters:
cart
- theCart
whose payments are to be locked.contextInfo
- context information around sandbox and multitenant state.- Returns:
- A
LockPaymentsResponse
containing the payment locks andPaymentSummaries
- Throws:
PaymentLockException
- if a lock could not be obtained.
-
unlockCartPayments
void unlockCartPayments(Collection<String> lockTokens, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Unlocks the cart's payments, based on the lock tokens that were previously obtained vialockCartPayments(Cart, ContextInfo)
.- Parameters:
lockTokens
- Tokens that can be used to unlock the cart's payments
-
finalizePaymentsForCheckout
UpdatePaymentsResponse finalizePaymentsForCheckout(String ownerId, Map<String, String> paymentLockTokens, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) The PaymentTransactionServices internally prepares and finalizes the payments for checkout.- Parameters:
ownerId
- the owner id of thePaymentSummaries
to finalizepaymentLockTokens
- Tokens that can be used to unlock the cart's paymentscontextInfo
- context information around sandbox and multitenant state.
-
blockCustomerMutabilityForPayments
UpdatePaymentsResponse blockCustomerMutabilityForPayments(String ownerId, Map<String, String> paymentLockTokens, boolean markTransactionsIneligibleForAutoReversal, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Blocks customer mutability for the cart's payments.- Parameters:
ownerId
- the owner id of thePaymentSummaries
to finalizepaymentLockTokens
- Tokens that can be used to unlock the cart's paymentsmarkTransactionsIneligibleForAutoReversal
- Determines if the payments' transactions should be marked ineligible for automatic reversalcontextInfo
- context information around sandbox and multitenant state.
-
blockCustomerMutabilityForPaymentFinalization
UpdatePaymentsResponse blockCustomerMutabilityForPaymentFinalization(String cartId, Map<String, String> paymentLockTokens, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Blocks customer mutability for the cart's payments while payment finalization is completed. Note: this block can be removed viaremoveCustomerMutabilityBlockForPaymentFinalization(String, Map, ContextInfo)
if the customer chooses to opt-out of the finalization interaction.- Parameters:
cartId
- the id of the payment-owning cartpaymentLockTokens
- Tokens that can be used to unlock the cart's paymentscontextInfo
- context information around sandbox and multitenant state.
-
removeCustomerMutabilityBlockForPaymentFinalization
UpdatePaymentsResponse removeCustomerMutabilityBlockForPaymentFinalization(String cartId, Map<String, String> paymentLockTokens, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Unblocks customer mutability for the cart's payments.- Parameters:
cartId
- the id of the payment-owning cartpaymentLockTokens
- Tokens that can be used to unlock the cart's paymentscontextInfo
- context information around sandbox and multitenant state.
-
transferPaymentsToCSR
UpdatePaymentsResponse transferPaymentsToCSR(String ownerId, Map<String, String> paymentLockTokens, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) The PaymentTransactionServices internally prepares and transfers the payments to the CSR user. The expectation is that the payments will no longer be owned by the customer and cannot be accessed except by the CSR user.- Parameters:
ownerId
- the owner id of thePaymentSummaries
to transferpaymentLockTokens
- Tokens that can be used to unlock the cart's paymentscontextInfo
- context information around sandbox and multitenant state.
-
transferPaymentsToCSR
default UpdatePaymentsResponse transferPaymentsToCSR(String ownerId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
transferPaymentsToCustomer
UpdatePaymentsResponse transferPaymentsToCustomer(String ownerId, Map<String, String> paymentLockTokens, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) The PaymentTransactionServices internally prepares and transfers the payments to the customer user.- Parameters:
ownerId
- the owner id of thePaymentSummaries
to transferpaymentLockTokens
- Tokens that can be used to unlock the cart's paymentscontextInfo
- context information around sandbox and multitenant state.
-
transferPaymentsToCustomer
default UpdatePaymentsResponse transferPaymentsToCustomer(String ownerId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
claimTransactionsForRequest
@Deprecated(since="1.7.6", forRemoval=true) default void claimTransactionsForRequest(String paymentId, String requestId, String transactionType, boolean resetTransactionReversalState, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated, for removal: This API element is subject to removal in a future version.since 1.7.6, in favor ofclaimTransactionsForRequest(ClaimCheckoutTransactionsRequest, ContextInfo)
Updates the payment transaction request id with the new value, stores the previous value, clears transaction management state and management state reason.- Parameters:
paymentId
- the payment idrequestId
- id used to represent the request that produced this transaction e.g during checkouttransactionType
- the transaction typeresetTransactionReversalState
- reset or not the state of the transaction reversallockToken
- token granted to resource that owns the payment lockcontextInfo
- context information related to multitenancy
-
claimTransactionsForRequest
PaymentSummary claimTransactionsForRequest(ClaimCheckoutTransactionsRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the payment transaction request id with the new value, stores the previous value, clears transaction management state and management state reason.- Parameters:
request
- theClaimCheckoutTransactionsRequest
to claim the transactions for a checkout requestcontextInfo
- context information related to multitenancy
-
claimTransactionsForRequest(ClaimCheckoutTransactionsRequest, ContextInfo)