braintree / braintree_android

Braintree SDK for Android
https://developer.paypal.com/braintree/docs/start/hello-client/android/v4
MIT License
405 stars 232 forks source link

Users getting UserCanceledException on PayPal CustomTabs tokenization after minimizing the CustomTabs #953

Open LAMESGIT opened 5 months ago

LAMESGIT commented 5 months ago

Braintree SDK Version

4.33.0

Environment

Both

Android Version & Device

Google Pixel 4 - Android 13.0

Braintree dependencies

implementation 'com.braintreepayments.api:paypal:4.33.0'

Describe the bug

Hi, We have a feedback from one of our testers that the authorization in paypal webpage using Chrome CustomTabs cancels once he clicks the "minimize" button on the CustomTabs toolbar. We analyze the log and find Braintree returns "UserCanceledException: User canceled PayPal" from onPayPalFailure method.

To reproduce

  1. Install Chrome of which version at least 122 on the phone, and set it as the CustomTabs provider.
  2. Choose PayPal as the payment method and checkout (i.e. invoke PayPalClient.tokenizePayPalAccount method).
  3. Some users can see screen like this below: Screenshot_20240322-170944
  4. On the right of close button, there is a down arrow. Click it and the customTabs will be minimized, after that onPayPalFailure is called.

If you can't see the minimize button on CustomTabs toolbar, make sure the brand of the test phone is NOT Xiaomi. And if you still can't see the button, open chrome and open uri: chrome://flags/#cct-minimized, set the flag to ENABLED and check again.

Expected behavior

We don't wanna receive this UserCanceledException when minimize the customTabs. We hope the calling process can be waiting while the customTabs is minimized and receive token result after customTabs is truly cancelled. Also we did some analysis of the code logic, we think the minimization feature enabled by Chrome is the reason (may be wrong :) ), according to this doc about the overview of Android customTabs: https://developer.chrome.com/docs/android/custom-tabs. This feature is based on Picture-in-Picture in Android system. Once the customTabs is minimized, the checkout page would be resumed, and the PayPalLifecycleObserver would get ON_RESUME lifecycle event, which triggers the SDK flow.

Have a nice day~ :)

Screenshots

No response

sarahkoop commented 4 months ago

Hi @LAMESGIT - Thank you for reporting this issue. We are currently investigating this behavior and will post here when we have an update!

LAMESGIT commented 4 months ago

@sarahkoop Thanks a lot! It would be a great help to us. 😊