-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shopper insights rp1 feature include session #1235
Changes from all commits
7dedb0a
dedaf01
b1f1767
ebb92f1
7b06a23
a51d13b
737f16f
c4437cd
c6b72d5
e548542
c9f419a
179e35b
152b11e
073938b
fe9def0
41a47b0
c5c0c21
41c4f17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,17 +25,27 @@ public static PayPalVaultRequest createPayPalVaultRequest( | |
Context context, | ||
String buyerEmailAddress, | ||
String buyerPhoneCountryCode, | ||
String buyerPhoneNationalNumber | ||
String buyerPhoneNationalNumber, | ||
String shopperInsightsSessionId | ||
) { | ||
|
||
PayPalVaultRequest request = new PayPalVaultRequest(true); | ||
|
||
if (!buyerEmailAddress.isEmpty()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to change all these other params? It seems like it should be unaffected by this PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding is that the original code is potentially a run time crash if the value is null. In the case of the demo app and how its setup, setting the toggles to null didn't have an impact on this flow because the values would always be true. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok in that case do we need to check that it's not null and it's not empty? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, great catch! |
||
if (buyerEmailAddress != null && !buyerEmailAddress.isEmpty()) { | ||
request.setUserAuthenticationEmail(buyerEmailAddress); | ||
} | ||
|
||
if (!buyerPhoneCountryCode.isEmpty() && !buyerPhoneNationalNumber.isEmpty()) { | ||
request.setUserPhoneNumber(new PayPalPhoneNumber(buyerPhoneCountryCode, buyerPhoneNationalNumber)); | ||
if ((buyerPhoneCountryCode != null && !buyerPhoneCountryCode.isEmpty()) | ||
&& (buyerPhoneNationalNumber != null && !buyerPhoneNationalNumber.isEmpty())) { | ||
|
||
request.setUserPhoneNumber(new PayPalPhoneNumber( | ||
buyerPhoneCountryCode, | ||
buyerPhoneNationalNumber) | ||
); | ||
} | ||
|
||
if (shopperInsightsSessionId != null && !shopperInsightsSessionId.isEmpty()) { | ||
request.setShopperSessionId(shopperInsightsSessionId); | ||
} | ||
|
||
if (Settings.isPayPalAppSwithEnabled(context)) { | ||
|
@@ -111,16 +121,25 @@ public static PayPalCheckoutRequest createPayPalCheckoutRequest( | |
String amount, | ||
String buyerEmailAddress, | ||
String buyerPhoneCountryCode, | ||
String buyerPhoneNationalNumber | ||
String buyerPhoneNationalNumber, | ||
String shopperInsightsSessionId | ||
) { | ||
PayPalCheckoutRequest request = new PayPalCheckoutRequest(amount, true); | ||
|
||
if (!buyerEmailAddress.isEmpty()) { | ||
if (buyerEmailAddress != null && !buyerEmailAddress.isEmpty()) { | ||
request.setUserAuthenticationEmail(buyerEmailAddress); | ||
} | ||
|
||
if (!buyerPhoneCountryCode.isEmpty() && !buyerPhoneNationalNumber.isEmpty()) { | ||
request.setUserPhoneNumber(new PayPalPhoneNumber(buyerPhoneCountryCode, buyerPhoneNationalNumber)); | ||
if ((buyerPhoneCountryCode != null && !buyerPhoneCountryCode.isEmpty()) | ||
&& (buyerPhoneNationalNumber != null && !buyerPhoneNationalNumber.isEmpty())) { | ||
request.setUserPhoneNumber(new PayPalPhoneNumber( | ||
buyerPhoneCountryCode, | ||
buyerPhoneNationalNumber) | ||
); | ||
} | ||
|
||
if (shopperInsightsSessionId != null && !shopperInsightsSessionId.isEmpty()) { | ||
request.setShopperSessionId(shopperInsightsSessionId); | ||
} | ||
|
||
request.setDisplayName(Settings.getPayPalDisplayName(context)); | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -60,12 +60,14 @@ class ShopperInsightsFragment : BaseFragment() { | |||
private lateinit var venmoStartedPendingRequest: VenmoPendingRequest.Started | ||||
private lateinit var paypalStartedPendingRequest: PayPalPendingRequest.Started | ||||
|
||||
private var shopperSessionId: String = "test-shopper-session-id" | ||||
|
||||
override fun onCreateView( | ||||
inflater: LayoutInflater, | ||||
container: ViewGroup?, | ||||
savedInstanceState: Bundle? | ||||
): View? { | ||||
shopperInsightsClient = ShopperInsightsClient(requireContext(), authStringArg, "test-shopper-session-id") | ||||
shopperInsightsClient = ShopperInsightsClient(requireContext(), authStringArg, shopperSessionId) | ||||
|
||||
venmoClient = VenmoClient(requireContext(), super.getAuthStringArg(), null) | ||||
payPalClient = PayPalClient( | ||||
|
@@ -229,7 +231,9 @@ class ShopperInsightsFragment : BaseFragment() { | |||
activity, | ||||
emailInput.editText?.text.toString(), | ||||
countryCodeInput.editText?.text.toString(), | ||||
nationalNumberInput.editText?.text.toString() | ||||
nationalNumberInput.editText?.text.toString(), | ||||
shopperSessionId | ||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
) | ||||
) { authRequest -> | ||||
when (authRequest) { | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it looks like there are some extra spaces for the 2 null properties here