Interface PaymentProvider
- All Known Implementing Classes:
ExternalPaymentProvider
public interface PaymentProvider
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:
- Sunny Yu
-
Method Summary
Modifier and TypeMethodDescriptiondefault TransactionExecutionRequest
buildTransactionExecutionRequest
(String paymentId, TransactionType transactionType, javax.money.MonetaryAmount transactionAmount, String sourceEntityType, String sourceEntityId) Builds aTransactionExecutionRequest
based on the given properties.buildTransactionExecutionRequest
(String paymentId, TransactionType transactionType, javax.money.MonetaryAmount transactionAmount, String parentSourceEntityType, String parentSourceEntityId, String sourceEntityType, String sourceEntityId) Builds aTransactionExecutionRequest
based on the given properties.executeCapture
(PaymentSummary paymentSummary, String lockToken, TransactionExecutionRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Captures an amount for the given payment.executeRefund
(PaymentSummary paymentSummary, String lockToken, TransactionExecutionRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Refunds an amount for the given payment.executeReverseAuthorize
(PaymentSummary paymentSummary, String lockToken, TransactionExecutionRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reverse authorizes an amount for the given payment.lockPayments
(List<String> paymentIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Locks the given payments to ensure that all of the work done for capturing, reverse authorizing, and refunding process in general is consistently interacting with payments that will not change.default List<PaymentSummary>
readByCartId
(String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a list ofPaymentSummaries
that belong to the givenOrder.getCartId()
.default List<PaymentSummary>
readByOwnerTypeAndOwnerId
(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.readByPaymentOwnerAndTransactionSourceEntity
(String ownerType, String ownerId, String sourceEntityType, String sourceEntityId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a list ofPaymentSummaries
that belong to the given payment owner and payment transaction source entity.readByPaymentOwnerAndTransactionSourceEntityTypes
(String ownerType, String ownerId, Set<String> sourceEntityTypes, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a list ofPaymentSummaries
that belong to the given payment owner and payment transaction source entity types.void
unlockPayments
(Collection<String> lockTokens, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Unlocks the payments, based on the lock tokens that were previously obtained vialockPayments(List, ContextInfo)
.
-
Method Details
-
readByOwnerTypeAndOwnerId
default List<PaymentSummary> readByOwnerTypeAndOwnerId(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
-
readByPaymentOwnerAndTransactionSourceEntity
List<PaymentSummary> readByPaymentOwnerAndTransactionSourceEntity(String ownerType, String ownerId, @Nullable String sourceEntityType, @Nullable String sourceEntityId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a list ofPaymentSummaries
that belong to the given payment owner and payment transaction source entity.- 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 payment owner and payment transaction source entity
-
readByPaymentOwnerAndTransactionSourceEntityTypes
List<PaymentSummary> readByPaymentOwnerAndTransactionSourceEntityTypes(String ownerType, String ownerId, Set<String> sourceEntityTypes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a list ofPaymentSummaries
that belong to the given payment owner and payment transaction source entity types.- Parameters:
ownerType
- the owner type of thePaymentSummaries
to retrieveownerId
- the owner id of thePaymentSummaries
to retrievesourceEntityTypes
- The set of source entity types to use for filteringcontextInfo
- context information around sandbox and multitenant state- Returns:
- a list of
PaymentSummaries
based on the given payment owner and payment transaction source entity
-
readByCartId
default List<PaymentSummary> readByCartId(String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a list ofPaymentSummaries
that belong to the givenOrder.getCartId()
.Using
Order.getCartId()
instead ofOrder.getId()
here because the payments are owned by Cart instead of Order.- Parameters:
cartId
- theOrder.getCartId()
of thePaymentSummaries
to retrievecontextInfo
- context information around sandbox and multitenant state.- Returns:
- a list of
PaymentSummaries
that belong to the givenOrder.getCartId()
-
lockPayments
Map<String,String> lockPayments(List<String> paymentIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Locks the given payments to ensure that all of the work done for capturing, reverse authorizing, and refunding 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 capturing, reverse authorizing, and refunding process can sufficiently be contained within the payment lock TTL. This can be configured in PaymentTransactionServices.- Parameters:
paymentIds
- the ids of the 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.
-
unlockPayments
void unlockPayments(Collection<String> lockTokens, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Unlocks the payments, based on the lock tokens that were previously obtained vialockPayments(List, ContextInfo)
.- Parameters:
lockTokens
- Tokens that can be used to unlock the payments
-
executeCapture
TransactionExecutionResponse executeCapture(PaymentSummary paymentSummary, String lockToken, TransactionExecutionRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Captures an amount for the given payment.- Parameters:
paymentSummary
- the payment to capture the amount fromlockToken
- the token that owns the payment lockrequest
- theTransactionExecutionRequest
to executecontextInfo
- context information around sandbox and multitenant state- Returns:
- the
TransactionExecutionResponse
for the capture transaction
-
executeReverseAuthorize
TransactionExecutionResponse executeReverseAuthorize(PaymentSummary paymentSummary, String lockToken, TransactionExecutionRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reverse authorizes an amount for the given payment.- Parameters:
paymentSummary
- the payment to reverse authorize the amount fromlockToken
- the token that owns the payment lockrequest
- theTransactionExecutionRequest
to executecontextInfo
- context information around sandbox and multitenant state- Returns:
- the
TransactionExecutionResponse
for the reverse authorize transaction
-
executeRefund
TransactionExecutionResponse executeRefund(PaymentSummary paymentSummary, String lockToken, TransactionExecutionRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Refunds an amount for the given payment.This method assumes that the parent transaction of this execution belongs to the same source entity, hence using
sourceEntityType
asparentSourceEntityType
.- Parameters:
paymentSummary
- the payment to refund the amount fromlockToken
- the token that owns the payment lockrequest
- theTransactionExecutionRequest
to executecontextInfo
- context information around sandbox and multitenant state- Returns:
- the
TransactionExecutionResponse
for the refund transaction
-
buildTransactionExecutionRequest
default TransactionExecutionRequest buildTransactionExecutionRequest(String paymentId, TransactionType transactionType, javax.money.MonetaryAmount transactionAmount, String sourceEntityType, String sourceEntityId) Builds aTransactionExecutionRequest
based on the given properties.This method sets the parent source entity type and id to
null
by default.- Parameters:
paymentId
- theTransactionExecutionRequest.getPaymentId()
transactionType
- theTransactionExecutionRequest.getTransactionType()
transactionAmount
- theTransactionExecutionRequest.getTransactionAmount()
sourceEntityType
- theTransactionExecutionRequest.getSourceEntityType()
sourceEntityId
- theTransactionExecutionRequest.getSourceEntityId()
- Returns:
- a
TransactionExecutionRequest
based on the given properties
-
buildTransactionExecutionRequest
TransactionExecutionRequest buildTransactionExecutionRequest(String paymentId, TransactionType transactionType, javax.money.MonetaryAmount transactionAmount, @Nullable String parentSourceEntityType, @Nullable String parentSourceEntityId, String sourceEntityType, String sourceEntityId) Builds aTransactionExecutionRequest
based on the given properties.- Parameters:
paymentId
- theTransactionExecutionRequest.getPaymentId()
transactionType
- theTransactionExecutionRequest.getTransactionType()
transactionAmount
- theTransactionExecutionRequest.getTransactionAmount()
parentSourceEntityType
- theTransactionExecutionRequest.getParentSourceEntityType()
parentSourceEntityId
- theTransactionExecutionRequest.getParentSourceEntityId()
sourceEntityType
- theTransactionExecutionRequest.getSourceEntityType()
sourceEntityId
- theTransactionExecutionRequest.getSourceEntityId()
- Returns:
- a
TransactionExecutionRequest
based on the given properties
-