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 as Order
REQ - The request type such as OrdersCreateRequest
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 Details

    • AbstractPayPalRequest

      public AbstractPayPalRequest(PayPalClientProvider clientProvider, org.broadleafcommerce.common.payment.dto.PaymentRequestDTO paymentRequest)
  • Method Details

    • execute

      public PayPalResponse execute()
      Description copied from interface: PayPalRequest
      Executes this request if valid.
      Specified by:
      execute in interface PayPalRequest
      Returns:
      The AbstractPayPalResponse wrapper around the response from PayPal.
    • isValid

      protected boolean isValid()
      Whether this is configured correctly and can execute the request. Relies upon isValidInternal() and whether the request has already been executed.
      Returns:
      Whether this is configured correctly and can execute the request.
    • configureRequest

      protected void configureRequest(org.broadleafcommerce.common.payment.dto.PaymentRequestDTO paymentRequest)
      Configures request with content and headers. Defers to buildRequest() for most of the work.
    • getClient

      protected com.paypal.core.PayPalHttpClient getClient()
      Convenience method for getting the PayPalClientProvider.getClient() from clientProvider.
      Returns:
      clientProvider.client
    • buildRequest

      protected abstract REQ buildRequest()
      Method to build out request and provide it the implementation-specific configuration such as headers and request body.
      Returns:
      The configured request
    • executeInternal

      protected abstract AbstractPayPalResponse<RES> executeInternal() throws IOException
      Executes the configured request using the PayPalHttpClient.
      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()
    • getPaymentRequest

      protected org.broadleafcommerce.common.payment.dto.PaymentRequestDTO getPaymentRequest()
    • getRequest

      protected REQ getRequest()
    • isExecuted

      protected boolean isExecuted()