Skip to content

Commit

Permalink
Check for null and empty strings for request properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
warmkesselj committed Dec 6, 2024
1 parent 152b11e commit 073938b
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 073938b

Please sign in to comment.