Class ExternalPaymentProvider
- java.lang.Object
-
- com.broadleafcommerce.orderoperation.service.provider.external.AbstractExternalProvider
-
- com.broadleafcommerce.orderoperation.service.provider.external.ExternalPaymentProvider
-
- All Implemented Interfaces:
PaymentProvider
public class ExternalPaymentProvider extends AbstractExternalProvider implements PaymentProvider
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_HEADER_PAYMENT_LOCK_TOKEN
static String
DEFAULT_HEADER_PAYMENT_VERSION
-
Fields inherited from class com.broadleafcommerce.orderoperation.service.provider.external.AbstractExternalProvider
RSQL_FILTER_PARAM
-
-
Constructor Summary
Constructors Constructor Description ExternalPaymentProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalPaymentProperties properties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TransactionExecutionRequest
buildTransactionExecutionRequest(String paymentId, TransactionType transactionType, javax.money.MonetaryAmount transactionAmount, String parentSourceEntityType, String parentSourceEntityId, String sourceEntityType, String sourceEntityId)
Builds aTransactionExecutionRequest
based on the given properties.TransactionExecutionResponse
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)
TransactionExecutionResponse
executeRefund(PaymentSummary paymentSummary, String lockToken, TransactionExecutionRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Refunds an amount for the given payment.TransactionExecutionResponse
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
getBaseUri()
Gets the base URI common to all requests this provider will make.protected org.springframework.core.ParameterizedTypeReference<Map<String,String>>
getMapType()
Gets the type reference for a list of item list items.protected Map<String,Object>
getPaymentIdVariables(String paymentId)
protected ExternalPaymentProperties
getProperties()
protected String
getServiceClient()
Map<String,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.List<PaymentSummary>
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.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
executeRequest, getHeaders, getObjectMapper, getTypeFactory, getWebClient, 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 Detail
-
DEFAULT_HEADER_PAYMENT_VERSION
public static final String DEFAULT_HEADER_PAYMENT_VERSION
- See Also:
- Constant Field Values
-
DEFAULT_HEADER_PAYMENT_LOCK_TOKEN
public static final String DEFAULT_HEADER_PAYMENT_LOCK_TOKEN
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
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
-
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
-
getMapType
protected org.springframework.core.ParameterizedTypeReference<Map<String,String>> 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
protected String getServiceClient()
-
getProperties
protected ExternalPaymentProperties getProperties()
-
-