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 utilizesWebClient
to make requests to an external REST API.- Author:
- Dima Myroniuk (dmyroniuk), Sunny Yu
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
archivePayment(String paymentId, Integer version, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Archives the payment based on the provided id and version.Map<String,String>
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
.PaymentSummary
patchPayment(UpdatePaymentRequest updatePaymentRequest, Integer version, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Updates the payment based on the providedUpdatePaymentRequest
.List<P>
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.default List<P>
readByCartId(@NonNull String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Retrieves a list ofPaymentSummaries
that belong to the givenCart.getId()
.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 Detail
-
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 versioncontext
- Context information related to multitenancy- Returns:
- the updated payment summary.
-
archivePayment
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
-
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.
-
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
-
-