Class AbstractPayPalRequest<RES>
- java.lang.Object
-
- com.broadleafcommerce.paypal.micro.domain.api.AbstractPayPalRequest<RES>
-
- Type Parameters:
RES
- The response content type such asOrder
- All Implemented Interfaces:
PayPalRequest
- Direct Known Subclasses:
PayPalAuthorizationRetrievalRequest
,PayPalAuthorizeRequest
,PayPalCaptureAuthRequest
,PayPalCaptureOrderRequest
,PayPalCreateOrderRequest
,PayPalOrderRetrievalRequest
,PayPalRefundRequest
,PayPalUpdateOrderRequest
,PayPalVoidAuthRequest
public abstract class AbstractPayPalRequest<RES> extends Object implements PayPalRequest
Represents a request to make against the PayPal REST APIs. It should encapsulate everything necessary to make the request and return a response.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPayPalRequest(@NonNull PayPalApiProvider payPalApiProvider, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected String
buildIdempotencyKey(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
protected void
configureRequestHeaders(@NonNull org.springframework.http.HttpHeaders httpHeaders)
PayPalResponse
execute()
Executes this request if valid.protected abstract AbstractPayPalResponse<RES>
executeInternal(String applicationId, String tenantId)
Executes the configured request using thePayPalApiProvider
.protected com.broadleafcommerce.paymentgateway.domain.PaymentRequest
getPaymentRequest()
protected PayPalApiProvider
getPayPalApiProvider()
protected boolean
isExecuted()
Whether the request has been executed.protected boolean
isValid()
Whetherthis
is configured correctly and can execute the request.protected abstract boolean
isValidInternal()
Implementation specific determination of whether the request can be executed.protected org.springframework.http.HttpHeaders
preferMinimalHeader(org.springframework.http.HttpHeaders httpHeaders)
protected void
preferRepresentationHeader(org.springframework.http.HttpHeaders httpHeaders)
-
-
-
Constructor Detail
-
AbstractPayPalRequest
protected AbstractPayPalRequest(@NonNull @NonNull PayPalApiProvider payPalApiProvider, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
-
Method Detail
-
execute
public PayPalResponse execute()
Description copied from interface:PayPalRequest
Executes this request if valid.- Specified by:
execute
in interfacePayPalRequest
- Returns:
- The
AbstractPayPalResponse
wrapper around the response from PayPal.
-
isValid
protected boolean isValid()
Whetherthis
is configured correctly and can execute the request. Relies uponisValidInternal()
and whether the request has already beenexecuted
.- Returns:
- Whether
this
is configured correctly and can execute the request.
-
preferMinimalHeader
protected org.springframework.http.HttpHeaders preferMinimalHeader(org.springframework.http.HttpHeaders httpHeaders)
-
preferRepresentationHeader
protected void preferRepresentationHeader(org.springframework.http.HttpHeaders httpHeaders)
-
configureRequestHeaders
protected void configureRequestHeaders(@NonNull @NonNull org.springframework.http.HttpHeaders httpHeaders)
-
buildIdempotencyKey
protected String buildIdempotencyKey(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
executeInternal
protected abstract AbstractPayPalResponse<RES> executeInternal(@Nullable String applicationId, @Nullable String tenantId) throws PayPalProviderApiException
Executes the configured request using thePayPalApiProvider
.- Parameters:
applicationId
- the application IDtenantId
- the tenant ID- Returns:
- The response from PayPal
- Throws:
PayPalProviderApiException
- Thrown if the request execution fails.
-
isValidInternal
protected abstract boolean isValidInternal()
Implementation specific determination of whether the request can be executed.- Returns:
- Whether the request can be executed or is in an erroneous state.
-
getPayPalApiProvider
protected PayPalApiProvider getPayPalApiProvider()
-
getPaymentRequest
protected com.broadleafcommerce.paymentgateway.domain.PaymentRequest getPaymentRequest()
-
isExecuted
protected boolean isExecuted()
Whether the request has been executed.
-
-