Class ExternalPaymentProvider<P extends PaymentSummary>
- java.lang.Object
-
- com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
-
- com.broadleafcommerce.cartoperation.service.provider.external.payments.ExternalPaymentProvider<P>
-
- All Implemented Interfaces:
PaymentProvider<P>
public class ExternalPaymentProvider<P extends PaymentSummary> extends AbstractExternalProvider implements PaymentProvider<P>
This particular implementation ofPaymentProvider
is designed to interact with the payment transaction service.- Author:
- Dima Myroniuk (dmyroniuk)
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_HEADER_PAYMENT_LOCK_TOKEN
static String
DEFAULT_HEADER_PAYMENT_VERSION
-
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 void
archivePayment(String paymentId, Integer version, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Archives the payment based on the provided id and version.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 org.springframework.core.ParameterizedTypeReference<ResponsePageGenerator<P>>
getPageType()
Gets the type reference for a page generator of item list items.protected ExternalPaymentProperties
getProperties()
protected String
getServiceClient()
protected org.springframework.core.ParameterizedTypeReference<P>
getType()
Gets the type reference for payment summary.Map<String,String>
lockCartPayments(@NonNull 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.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(@NonNull String ownerType, @NonNull String ownerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Retrieves a list ofPaymentSummaries
that belong to the given owner type and owner id.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 viaPaymentProvider.lockCartPayments(Cart, ContextInfo)
.-
Methods inherited from class com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
executeRequest, getHeaders, getObjectMapper, getTypeFactory, getWebClient, pageableToParams, uriVars
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.broadleafcommerce.cartoperation.service.provider.PaymentProvider
patchPayment, readByCartId
-
-
-
-
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
-
readAllByOwnerTypeAndOwnerId
public List<P> readAllByOwnerTypeAndOwnerId(@NonNull @NonNull String ownerType, @NonNull @NonNull String ownerId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:PaymentProvider
Retrieves a list ofPaymentSummaries
that belong to the given owner type and owner id.- Specified by:
readAllByOwnerTypeAndOwnerId
in interfacePaymentProvider<P extends PaymentSummary>
- Parameters:
ownerType
- the owner type of thePaymentSummaries
to retrieveownerId
- the owner id of thePaymentSummaries
to retrievecontext
- context information around sandbox and multitenant state.- Returns:
- a list of
PaymentSummaries
based on the given owner type and owner id
-
patchPayment
public PaymentSummary patchPayment(UpdatePaymentRequest updatePaymentRequest, Integer version, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:PaymentProvider
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.- Specified by:
patchPayment
in interfacePaymentProvider<P extends PaymentSummary>
- Parameters:
updatePaymentRequest
- the request payload used to update the paymentversion
- the payment versioncontext
- Context information related to multitenancy- Returns:
- the updated payment summary.
-
archivePayment
public void archivePayment(String paymentId, Integer version, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:PaymentProvider
Archives the payment based on the provided id and version.- Specified by:
archivePayment
in interfacePaymentProvider<P extends PaymentSummary>
- Parameters:
paymentId
- the context id of the paymentversion
- the payment versioncontext
- context information related to multitenancy
-
lockCartPayments
public Map<String,String> lockCartPayments(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:PaymentProvider
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.- Specified by:
lockCartPayments
in interfacePaymentProvider<P extends PaymentSummary>
- 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.
-
unlockCartPayments
public void unlockCartPayments(Collection<String> lockTokens, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:PaymentProvider
Unlocks the cart's payments, based on the lock tokens that were previously obtained viaPaymentProvider.lockCartPayments(Cart, ContextInfo)
.- Specified by:
unlockCartPayments
in interfacePaymentProvider<P extends PaymentSummary>
- Parameters:
lockTokens
- Tokens that can be used to unlock the cart's payments
-
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
-
getType
protected org.springframework.core.ParameterizedTypeReference<P> getType()
Gets the type reference for payment summary.- Returns:
- type reference for payment summary
-
getPageType
protected org.springframework.core.ParameterizedTypeReference<ResponsePageGenerator<P>> getPageType()
Gets the type reference for a page generator of item list items.- Returns:
- type reference for a page generator of item list items
-
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
-
getServiceClient
protected String getServiceClient()
-
getProperties
protected ExternalPaymentProperties getProperties()
-
-