Class DefaultPayPalCheckoutTransactionService

java.lang.Object
com.broadleafcommerce.paypal.micro.gateway.service.DefaultPayPalCheckoutTransactionService
All Implemented Interfaces:
com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService, com.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware, PayPalCheckoutTransactionService

public class DefaultPayPalCheckoutTransactionService extends Object implements PayPalCheckoutTransactionService
Author:
Nathan Moore
  • Constructor Details

  • Method Details

    • authorize

      public com.broadleafcommerce.paymentgateway.domain.PaymentResponse authorize(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
      Specified by:
      authorize in interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService
    • capture

      public com.broadleafcommerce.paymentgateway.domain.PaymentResponse capture(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
      Specified by:
      capture in interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService
    • authorizeAndCapture

      public com.broadleafcommerce.paymentgateway.domain.PaymentResponse authorizeAndCapture(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
      Specified by:
      authorizeAndCapture in interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService
    • reverseAuthorize

      public com.broadleafcommerce.paymentgateway.domain.PaymentResponse reverseAuthorize(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
      Specified by:
      reverseAuthorize in interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService
    • refund

      public com.broadleafcommerce.paymentgateway.domain.PaymentResponse refund(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
      Specified by:
      refund in interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionService
    • addAssertionHeaderForRefundOnBehalfOf

      protected void addAssertionHeaderForRefundOnBehalfOf(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
      This is only needed when using the Marketplaces and Platforms solution from PayPal. Specifically, see Issuing a Refund.

      Adds the PayPal-Auth-Assertion header to the paymentRequest to ensure it's included for refund requests, otherwise, the request will be considered unauthorized when attempting to refund on behalf of a seller.

      Parameters:
      paymentRequest - PaymentRequest DTO.
    • voidAuthorization

      protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse voidAuthorization(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.enums.TransactionType transactionType)
    • captureAuthorization

      protected PayPalCaptureAuthResponse captureAuthorization(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
      Executes a DefaultTransactionTypes.CAPTURE for the provided Authorization
      Parameters:
      paymentRequest - The request payload that should be used to form the transaction
      Returns:
      a PayPalCaptureAuthResponse
    • authorizeOrder

      protected PayPalAuthorizeResponse authorizeOrder(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
      Executes an DefaultTransactionTypes.AUTHORIZE transaction based on the provided PaymentRequest
      Parameters:
      paymentRequest - The request payload that should be used to form the transaction
      Returns:
      an PayPalAuthorizeResponse representing the final state of the transaction
    • retrieveAuthorization

      protected PayPalAuthorizationRetrievalResponse retrieveAuthorization(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
    • captureOrder

      protected PayPalCaptureOrderResponse captureOrder(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
      Executes an DefaultTransactionTypes.AUTHORIZE_AND_CAPTURE transaction based on the provided PaymentRequest. For PayPal, this captures the Order immediately with no authorization.
      Parameters:
      paymentRequest - The request payload that should be used to form the transaction
      Returns:
      a PayPalCaptureOrderResponse
    • voidAuthorization

      protected PayPalVoidAuthResponse voidAuthorization(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
      Executes a DefaultTransactionTypes.REVERSE_AUTH for the provided Authorization object. For PayPal, this means voiding the original authorization.
      Parameters:
      paymentRequest - The request payload that should be used to form the transaction
      Returns:
      the PayPalVoidAuthResponse
    • refundPayment

      protected PayPalRefundResponse refundPayment(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
      Executes a DefaultTransactionTypes.REFUND for the captured payment.
      Parameters:
      paymentRequest - The request payload that should be used to form the transaction
      Returns:
      a PayPalRefundResponse
    • processException

      @Deprecated(since="PayPal 3.0.4", forRemoval=true) protected void processException(@NonNull @NonNull Exception e, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method is responsible for levering the exception, paymentRequest, & transactionType to populate the paymentResponse instead of allowing the exception to be thrown.
      Parameters:
      e - the exception indicating a failed payment gateway transaction
      paymentResponse - the object that will hold the transaction results
      paymentRequest - the request that was used to execute the transaction
    • getGatewayType

      public String getGatewayType()
      Specified by:
      getGatewayType in interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware
    • getPaypalCheckoutService

      protected PayPalCheckoutProvider getPaypalCheckoutService()
    • getApiProvider

      protected PayPalApiProvider getApiProvider()
    • getPayPalOrderService

      protected PayPalOrderService getPayPalOrderService()
    • getProperties

      protected PayPalCheckoutApiProperties getProperties()
    • getRetryTemplate

      protected org.springframework.retry.support.RetryTemplate getRetryTemplate()
    • getUtils

      protected PayPalUtils getUtils()