Class PayPalUtils
java.lang.Object
com.broadleafcommerce.paypal.micro.gateway.service.util.PayPalUtils
- Author:
- Nathan Moore (nathandmoore)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertFromErrorJson(@NonNull org.springframework.web.reactive.function.client.WebClientResponseException ex) javax.money.MonetaryAmountconvertOrdersMoneyToMonetaryAmount(@NonNull Money money) javax.money.MonetaryAmountconvertPaymentsMoneyToMonetaryAmount(@NonNull Money money) convertResponseToJson(Object response) convertToOrdersMoney(javax.money.MonetaryAmount amount) convertToPaymentsMoney(javax.money.MonetaryAmount amount) protected StringgetErrorMessageAndDetails(String errorMessage, String errorDetails) protected com.fasterxml.jackson.databind.ObjectMapperjavax.money.MonetaryAmountprotected PayPalCheckoutApiPropertiesprotected booleanisPaymentDecline(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.protected booleanisPaymentMethodDecline(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.protected voidlogErrorDetailsIfPresent(String errorDetails, String message, Exception e) voidprocessException(@NonNull Exception e, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentRequest paymentRequest, com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) This method uses the exception andPaymentRequestto populate thePaymentResponseinstead of allowing the exception to be thrown.voidsetProperties(PayPalCheckoutApiProperties properties)
-
Constructor Details
-
PayPalUtils
public PayPalUtils(com.fasterxml.jackson.databind.ObjectMapper mapper)
-
-
Method Details
-
convertResponseToJson
-
convertFromErrorJson
public PayPalErrorResponse convertFromErrorJson(@NonNull @NonNull org.springframework.web.reactive.function.client.WebClientResponseException ex) -
getMonetaryAmountForAmountWithBreakdown
public javax.money.MonetaryAmount getMonetaryAmountForAmountWithBreakdown(AmountWithBreakdown amount) -
convertOrdersMoneyToMonetaryAmount
-
convertPaymentsMoneyToMonetaryAmount
public javax.money.MonetaryAmount convertPaymentsMoneyToMonetaryAmount(@NonNull @NonNull Money money) -
convertToPaymentsMoney
-
convertToOrdersMoney
-
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 andPaymentRequestto populate thePaymentResponseinstead of allowing the exception to be thrown.- Parameters:
e- the exception indicating a failed payment gateway transactionpaymentResponse- the object that will hold the transaction resultspaymentRequest- the request that was used to execute the transaction
-
isPaymentMethodDecline
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
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
-
getErrorMessageAndDetails
-
getMapper
protected com.fasterxml.jackson.databind.ObjectMapper getMapper() -
getProperties
-
setProperties
-