Class AbstractPayPalRequest<RES,REQ extends com.paypal.http.HttpRequest<RES>>
java.lang.Object
org.broadleafcommerce.vendor.paypal.service.payment.AbstractPayPalRequest<RES,REQ>
- Type Parameters:
RES- The response content type such asOrderREQ- 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
ConstructorsConstructorDescriptionAbstractPayPalRequest(PayPalClientProvider clientProvider, org.broadleafcommerce.common.payment.dto.PaymentRequestDTO paymentRequest) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract REQMethod to build outrequestand provide it the implementation-specific configuration such as headers and request body.protected voidconfigureRequest(org.broadleafcommerce.common.payment.dto.PaymentRequestDTO paymentRequest) Configuresrequestwith content and headers.execute()Executes this request if valid.protected abstract AbstractPayPalResponse<RES>Executes the configuredrequestusing thePayPalHttpClient.protected com.paypal.core.PayPalHttpClientConvenience method for getting thePayPalClientProvider.getClient()fromclientProvider.protected PayPalClientProviderprotected org.broadleafcommerce.common.payment.dto.PaymentRequestDTOprotected REQprotected booleanprotected booleanisValid()Whetherthisis configured correctly and can execute the request.protected abstract booleanImplementation specific determination of whether the request can be executed.
-
Constructor Details
-
AbstractPayPalRequest
public AbstractPayPalRequest(PayPalClientProvider clientProvider, org.broadleafcommerce.common.payment.dto.PaymentRequestDTO paymentRequest)
-
-
Method Details
-
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.
-
configureRequest
protected void configureRequest(org.broadleafcommerce.common.payment.dto.PaymentRequestDTO paymentRequest) Configuresrequestwith content and headers. Defers tobuildRequest()for most of the work. -
getClient
protected com.paypal.core.PayPalHttpClient getClient()Convenience method for getting thePayPalClientProvider.getClient()fromclientProvider.- Returns:
clientProvider.client
-
buildRequest
Method to build outrequestand provide it the implementation-specific configuration such as headers and request body.- Returns:
- The configured request
-
executeInternal
Executes the configuredrequestusing thePayPalHttpClient.- 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
-
getPaymentRequest
protected org.broadleafcommerce.common.payment.dto.PaymentRequestDTO getPaymentRequest() -
getRequest
-
isExecuted
protected boolean isExecuted()
-