Class AbstractPayPalRequest<RES,REQ extends com.paypal.http.HttpRequest<RES>>
- java.lang.Object
-
- com.broadleafcommerce.paypal.micro.domain.api.AbstractPayPalRequest<RES,REQ>
-
- Type Parameters:
RES
- The response content type such asOrder
REQ
- The request type such asOrdersCreateRequest
- All Implemented Interfaces:
PayPalRequest
- Direct Known Subclasses:
PayPalAuthorizationRetrievalRequest
,PayPalAuthorizeRequest
,PayPalCaptureAuthRequest
,PayPalCaptureOrderRequest
,PayPalCaptureRetrievalRequest
,PayPalCreateOrderRequest
,PayPalOrderRetrievalRequest
,PayPalReAuthorizeRequest
,PayPalRefundRequest
,PayPalUpdateOrderRequest
,PayPalVoidAuthRequest
public abstract class AbstractPayPalRequest<RES,REQ extends com.paypal.http.HttpRequest<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 Constructor Description AbstractPayPalRequest(@NonNull PayPalClientProvider clientProvider, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected abstract REQ
buildRequest()
Method to build outrequest
and provide it the implementation-specific configuration such as headers and request body.protected void
configureRequest(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
Configuresrequest
with content and headers.PayPalResponse
execute()
Executes this request if valid.protected AbstractPayPalResponse<RES>
executeInternal()
Deprecated.in favour ofexecuteInternal(String, String)
protected abstract AbstractPayPalResponse<RES>
executeInternal(String applicationId, String tenantId)
Executes the configuredrequest
using thegetClient(String, String)
PayPalHttpClient}.protected com.paypal.core.PayPalHttpClient
getClient()
Deprecated.in favour ofgetClient(String, String)
protected com.paypal.core.PayPalHttpClient
getClient(String applicationId, String tenantId)
Convenience method for getting thePayPalClientProvider.getClient(String, String)
()} fromclientProvider
.protected PayPalClientProvider
getClientProvider()
ThePayPalClientProvider
used to configure and execute requests.protected com.broadleafcommerce.paymentgateway.domain.PaymentRequest
getPaymentRequest()
protected REQ
getRequest()
TheHttpRequest
that is built to facilitate executing request.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.
-
-
-
Constructor Detail
-
AbstractPayPalRequest
public AbstractPayPalRequest(@NonNull @NonNull PayPalClientProvider clientProvider, @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.
-
configureRequest
protected void configureRequest(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
Configuresrequest
with content and headers. Defers tobuildRequest()
for most of the work.
-
getClient
@Deprecated(since="1.2.0") protected com.paypal.core.PayPalHttpClient getClient()
Deprecated.in favour ofgetClient(String, String)
Convenience method for getting thePayPalClientProvider.getClient()
fromclientProvider
.- Returns:
clientProvider.client
-
getClient
protected com.paypal.core.PayPalHttpClient getClient(@Nullable String applicationId, @Nullable String tenantId)
Convenience method for getting thePayPalClientProvider.getClient(String, String)
()} fromclientProvider
.- Parameters:
applicationId
- the application IDtenantId
- the tenant ID- Returns:
clientProvider.client
-
buildRequest
protected abstract REQ buildRequest()
Method to build outrequest
and provide it the implementation-specific configuration such as headers and request body.- Returns:
- The configured request
-
executeInternal
@Deprecated(since="1.2.0") protected AbstractPayPalResponse<RES> executeInternal() throws IOException
Deprecated.in favour ofexecuteInternal(String, String)
Executes the configuredrequest
using thePayPalHttpClient
.- Returns:
- The response from PayPal.
- Throws:
IOException
- Thrown if the request execution fails.
-
executeInternal
protected abstract AbstractPayPalResponse<RES> executeInternal(@Nullable String applicationId, @Nullable String tenantId) throws IOException
Executes the configuredrequest
using thegetClient(String, String)
PayPalHttpClient}.- Parameters:
applicationId
- the application IDtenantId
- the tenant ID- Returns:
- The response from PayPal
- Throws:
IOException
- 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.
-
getClientProvider
protected PayPalClientProvider getClientProvider()
ThePayPalClientProvider
used to configure and execute requests.
-
getPaymentRequest
protected com.broadleafcommerce.paymentgateway.domain.PaymentRequest getPaymentRequest()
-
getRequest
protected REQ getRequest()
TheHttpRequest
that is built to facilitate executing request.
-
isExecuted
protected boolean isExecuted()
Whether the request has been executed.
-
-