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 protectedAbstractPayPalRequest(@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 StringbuildIdempotencyKey(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)protected voidconfigureRequestHeaders(@NonNull org.springframework.http.HttpHeaders httpHeaders)PayPalResponseexecute()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.PaymentRequestgetPaymentRequest()protected PayPalApiProvidergetPayPalApiProvider()protected booleanisExecuted()Whether the request has been executed.protected booleanisValid()Whetherthisis configured correctly and can execute the request.protected abstract booleanisValidInternal()Implementation specific determination of whether the request can be executed.protected org.springframework.http.HttpHeaderspreferMinimalHeader(org.springframework.http.HttpHeaders httpHeaders)protected voidpreferRepresentationHeader(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:PayPalRequestExecutes this request if valid.- Specified by:
executein interfacePayPalRequest- Returns:
- The
AbstractPayPalResponsewrapper around the response from PayPal.
-
isValid
protected boolean isValid()
Whetherthisis configured correctly and can execute the request. Relies uponisValidInternal()and whether the request has already beenexecuted.- Returns:
- Whether
thisis 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.
-
-