Class ExternalPaymentProvider
java.lang.Object
com.broadleafcommerce.orderoperation.service.provider.external.AbstractExternalProvider
com.broadleafcommerce.orderoperation.service.provider.external.ExternalPaymentProvider
- All Implemented Interfaces:
PaymentProvider
-
Field Summary
Fields inherited from class com.broadleafcommerce.orderoperation.service.provider.external.AbstractExternalProvider
ENTITY_NOT_FOUND, RSQL_FILTER_PARAM
-
Constructor Summary
ConstructorDescriptionExternalPaymentProvider
(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalPaymentProperties properties) -
Method Summary
Modifier and TypeMethodDescriptionbuildTransactionExecutionRequest
(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.protected TransactionExecutionResponse
executePaymentTransaction
(String executionPath, TransactionExecutionRequest executionRequest, Integer paymentVersion, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) 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.protected org.springframework.web.util.UriComponentsBuilder
Gets the base URI common to all requests this provider will make.Gets the type reference for a list of item list items.getPaymentIdVariables
(String paymentId) protected ExternalPaymentProperties
protected String
lockPayments
(@NonNull 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.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 viaPaymentProvider.lockPayments(List, ContextInfo)
.Methods inherited from class com.broadleafcommerce.orderoperation.service.provider.external.AbstractExternalProvider
buildNotFoundException, executeRequest, getHeaders, getObjectMapper, getTypeFactory, getWebClient, isEntityNotFound, pageableToParams
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.orderoperation.service.provider.PaymentProvider
buildTransactionExecutionRequest, readByCartId, readByOwnerTypeAndOwnerId
-
Field Details
-
DEFAULT_HEADER_PAYMENT_VERSION
- See Also:
-
DEFAULT_HEADER_PAYMENT_LOCK_TOKEN
- See Also:
-
-
Constructor Details
-
ExternalPaymentProvider
public ExternalPaymentProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalPaymentProperties properties)
-
-
Method Details
-
readByPaymentOwnerAndTransactionSourceEntity
public List<PaymentSummary> readByPaymentOwnerAndTransactionSourceEntity(String ownerType, String ownerId, @Nullable String sourceEntityType, @Nullable String sourceEntityId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PaymentProvider
Retrieves a list ofPaymentSummaries
that belong to the given payment owner and payment transaction source entity.- Specified by:
readByPaymentOwnerAndTransactionSourceEntity
in interfacePaymentProvider
- 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
public List<PaymentSummary> readByPaymentOwnerAndTransactionSourceEntityTypes(String ownerType, String ownerId, Set<String> sourceEntityTypes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PaymentProvider
Retrieves a list ofPaymentSummaries
that belong to the given payment owner and payment transaction source entity types.- Specified by:
readByPaymentOwnerAndTransactionSourceEntityTypes
in interfacePaymentProvider
- 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
-
lockPayments
public Map<String,String> lockPayments(@NonNull @NonNull List<String> paymentIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PaymentProvider
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.- Specified by:
lockPayments
in interfacePaymentProvider
- 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.
-
unlockPayments
public void unlockPayments(Collection<String> lockTokens, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PaymentProvider
Unlocks the payments, based on the lock tokens that were previously obtained viaPaymentProvider.lockPayments(List, ContextInfo)
.- Specified by:
unlockPayments
in interfacePaymentProvider
- Parameters:
lockTokens
- Tokens that can be used to unlock the payments
-
executeCapture
public TransactionExecutionResponse executeCapture(PaymentSummary paymentSummary, String lockToken, TransactionExecutionRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PaymentProvider
Captures an amount for the given payment.- Specified by:
executeCapture
in interfacePaymentProvider
- 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
public TransactionExecutionResponse executeReverseAuthorize(PaymentSummary paymentSummary, String lockToken, TransactionExecutionRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PaymentProvider
Reverse authorizes an amount for the given payment.- Specified by:
executeReverseAuthorize
in interfacePaymentProvider
- 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
public TransactionExecutionResponse executeRefund(PaymentSummary paymentSummary, String lockToken, TransactionExecutionRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PaymentProvider
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
.- Specified by:
executeRefund
in interfacePaymentProvider
- 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
-
executePaymentTransaction
protected TransactionExecutionResponse executePaymentTransaction(String executionPath, TransactionExecutionRequest executionRequest, Integer paymentVersion, String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
buildTransactionExecutionRequest
public TransactionExecutionRequest buildTransactionExecutionRequest(String paymentId, TransactionType transactionType, javax.money.MonetaryAmount transactionAmount, String parentSourceEntityType, String parentSourceEntityId, String sourceEntityType, String sourceEntityId) Description copied from interface:PaymentProvider
Builds aTransactionExecutionRequest
based on the given properties.- Specified by:
buildTransactionExecutionRequest
in interfacePaymentProvider
- 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
-
getPaymentIdVariables
-
getMapType
Gets the type reference for a list of item list items.- Returns:
- type reference for a list of item list items
-
getBaseUri
protected org.springframework.web.util.UriComponentsBuilder getBaseUri()Gets the base URI common to all requests this provider will make.- Returns:
- a URI components builder with the base URI set up
-
getServiceClient
-
getProperties
-