From 073938bc021ca330c7e440e66917cfa85408551b Mon Sep 17 00:00:00 2001 From: Justin Warmkessel Date: Fri, 6 Dec 2024 14:49:27 -0800 Subject: [PATCH] Check for null and empty strings for request properties. --- .../demo/PayPalRequestFactory.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Demo/src/main/java/com/braintreepayments/demo/PayPalRequestFactory.java b/Demo/src/main/java/com/braintreepayments/demo/PayPalRequestFactory.java index dc9be1be1c..2331067882 100644 --- a/Demo/src/main/java/com/braintreepayments/demo/PayPalRequestFactory.java +++ b/Demo/src/main/java/com/braintreepayments/demo/PayPalRequestFactory.java @@ -31,7 +31,7 @@ public static PayPalVaultRequest createPayPalVaultRequest( PayPalVaultRequest request = new PayPalVaultRequest(true); - if (buyerEmailAddress != null && !buyerEmailAddress.isEmpty() ) { + if (buyerEmailAddress != null && !buyerEmailAddress.isEmpty()) { request.setUserAuthenticationEmail(buyerEmailAddress); } @@ -126,15 +126,19 @@ public static PayPalCheckoutRequest createPayPalCheckoutRequest( ) { PayPalCheckoutRequest request = new PayPalCheckoutRequest(amount, true); - if (buyerEmailAddress != null) { + if (buyerEmailAddress != null && !buyerEmailAddress.isEmpty()) { request.setUserAuthenticationEmail(buyerEmailAddress); } - if (buyerPhoneCountryCode != null && buyerPhoneNationalNumber != null) { - request.setUserPhoneNumber(new PayPalPhoneNumber(buyerPhoneCountryCode, buyerPhoneNationalNumber)); + if ((buyerPhoneCountryCode != null && !buyerPhoneCountryCode.isEmpty()) + && (buyerPhoneNationalNumber != null && !buyerPhoneNationalNumber.isEmpty())) { + request.setUserPhoneNumber(new PayPalPhoneNumber( + buyerPhoneCountryCode, + buyerPhoneNationalNumber) + ); } - if (shopperInsightsSessionId != null) { + if (shopperInsightsSessionId != null && !shopperInsightsSessionId.isEmpty()) { request.setShopperSessionId(shopperInsightsSessionId); }