java.lang.Object
com.broadleafcommerce.paypal.micro.gateway.service.util.PayPalUtils

public class PayPalUtils extends Object
Author:
Nathan Moore (nathandmoore)
  • Constructor Details

    • PayPalUtils

      public PayPalUtils(com.fasterxml.jackson.databind.ObjectMapper mapper)
  • Method Details

    • convertResponseToJson

      @Nullable public String convertResponseToJson(Object response)
    • convertFromErrorJson

      public PayPalErrorResponse convertFromErrorJson(@NonNull @NonNull org.springframework.web.reactive.function.client.WebClientResponseException ex)
    • getMonetaryAmountForAmountWithBreakdown

      public javax.money.MonetaryAmount getMonetaryAmountForAmountWithBreakdown(AmountWithBreakdown amount)
    • convertOrdersMoneyToMonetaryAmount

      public javax.money.MonetaryAmount convertOrdersMoneyToMonetaryAmount(@NonNull @NonNull Money money)
    • convertPaymentsMoneyToMonetaryAmount

      public javax.money.MonetaryAmount convertPaymentsMoneyToMonetaryAmount(@NonNull @NonNull Money money)
    • convertToPaymentsMoney

      public Optional<Money> convertToPaymentsMoney(@Nullable javax.money.MonetaryAmount amount)
    • convertToOrdersMoney

      public Optional<Money> convertToOrdersMoney(@Nullable javax.money.MonetaryAmount amount)
    • processException

      public void processException(@NonNull @NonNull Exception e, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest, @Nullable com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse)
      This method uses the exception and PaymentRequest 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
    • isPaymentMethodDecline

      protected boolean isPaymentMethodDecline(String errorCode)
      Since PayPal uses a 400 HTTP response for many different types of failures, this method leverages the errorCode to determine if there was an error in the processing of the payment method. For example, an incorrect card number, expiration date, etc.
      Parameters:
      errorCode - the error code returned by PayPal
      Returns:
      whether or not the failure was due to the payment method being declined
      See Also:
      • DefaultTransactionFailureTypes.INVALID_PAYMENT_METHOD
    • isPaymentDecline

      protected boolean isPaymentDecline(String errorCode)
      Since PayPal uses a 400 HTTP response for many different types of failures, this method leverages the errorCode to determine if there was an error in the processing of the payment. For example, a credit card decline should be considered a processing failure, whereas a request validation issue would not.
      Parameters:
      errorCode - the error code returned by PayPal
      Returns:
      whether or not the failure was due to the payment method being declined
    • logErrorDetailsIfPresent

      protected void logErrorDetailsIfPresent(String errorDetails, String message, Exception e)
    • getErrorMessageAndDetails

      protected String getErrorMessageAndDetails(String errorMessage, String errorDetails)
    • getMapper

      protected com.fasterxml.jackson.databind.ObjectMapper getMapper()
    • getProperties

      protected PayPalCheckoutApiProperties getProperties()
    • setProperties

      @Autowired public void setProperties(PayPalCheckoutApiProperties properties)