Class DefaultPayPalClientProvider
- java.lang.Object
-
- com.broadleafcommerce.paypal.micro.service.DefaultPayPalClientProvider
-
- All Implemented Interfaces:
PayPalClientProvider
public class DefaultPayPalClientProvider extends Object implements PayPalClientProvider
- Author:
- Nathan Moore (nathandmoore)
-
-
Constructor Summary
Constructors Constructor Description DefaultPayPalClientProvider(@NonNull PayPalCheckoutApiProperties properties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
buildIdempotencyKey(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
Builds or gathers the idempotencyKey for the request.void
configureRequest(@NonNull com.paypal.http.HttpRequest<?> request, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
Configures thePayPal request
based on thePaymentRequest
.com.paypal.core.PayPalHttpClient
getClient(String applicationId, String tenantId)
Returns thePayPalHttpClient
for the specified tenant and application ids.protected PayPalCheckoutApiProperties
getProperties()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.broadleafcommerce.paypal.micro.service.PayPalClientProvider
getClient
-
-
-
-
Constructor Detail
-
DefaultPayPalClientProvider
public DefaultPayPalClientProvider(@NonNull @NonNull PayPalCheckoutApiProperties properties)
-
-
Method Detail
-
getClient
@Cacheable("payPalHttpClient") public com.paypal.core.PayPalHttpClient getClient(@Nullable String applicationId, @Nullable String tenantId)
Description copied from interface:PayPalClientProvider
Returns thePayPalHttpClient
for the specified tenant and application ids.- Specified by:
getClient
in interfacePayPalClientProvider
- Parameters:
applicationId
- the application IDtenantId
- the tenant ID- Returns:
- the configured
PayPalHttpClient
.
-
configureRequest
public void configureRequest(@NonNull @NonNull com.paypal.http.HttpRequest<?> request, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
Description copied from interface:PayPalClientProvider
Configures thePayPal request
based on thePaymentRequest
. This will add the request ID and various headers common to all requests.- Specified by:
configureRequest
in interfacePayPalClientProvider
- Parameters:
request
- TheHttpRequest
to configurepaymentRequest
- ThePaymentRequest
sent to the gateway
-
buildIdempotencyKey
protected String buildIdempotencyKey(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
Builds or gathers the idempotencyKey for the request. This value will guarantee that the request cannot be processed twice & that if the request is made twice, that the second response will be the same as the first response.Note: this value must be unique for each transaction type. For example, if we want to authorize & later capture a PayPal
Order
, the capture request's idempotency key must be different than the authorization request's idempotency key.- Parameters:
paymentRequest
- the request that will be sent to PayPal- Returns:
- the idempotency key
-
getProperties
protected PayPalCheckoutApiProperties getProperties()
-
-