Class AbstractPayPalRequest<RES>

java.lang.Object
com.broadleafcommerce.paypal.micro.domain.api.AbstractPayPalRequest<RES>
Type Parameters:
RES - The response content type such as Order
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 Details

    • AbstractPayPalRequest

      protected AbstractPayPalRequest(@NonNull @NonNull PayPalApiProvider payPalApiProvider, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest 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.
    • 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 the PayPalApiProvider.
      Parameters:
      applicationId - the application ID
      tenantId - 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.