braintree / braintree-android-drop-in

Braintree Drop-In SDK for Android
https://developers.braintreepayments.com/guides/drop-in/android/v2
MIT License
124 stars 79 forks source link

UserCanceledException if the app is killed by the system while in background #463

Open matteo-goghero-leitha opened 8 months ago

matteo-goghero-leitha commented 8 months ago

Braintree SDK Version

6.13.0

Environment

Sandbox

Android Version & Device

Google Pixel 4a - Android 14 (but issue present in every android version)

Braintree dependencies

implementation("com.braintreepayments.api:drop-in:6.13.0")

Describe the bug

After launching DropIn payment flow, and while the DropIn activity is shown, if the app is put in the background (let's say to open the banking app to get a confirmation code) and it is killed by the system (low-memory kill or background process policy set to "No background processes") when the user returns to the app the DropIn API will throw UserCanceledException preventing the user to complete the payment process.

To reproduce

  1. Launch DropIn
  2. Select payment method
  3. Wait for the card information screen or bank code verification screen
  4. Put the app in the background by pressing the home button
  5. Kill the app process via adb or via android studio logcat button "Kill process" (to simulate the system killing the app)
  6. Return to the app by clicking on the app icon or from the recent apps screen
  7. Complete the payment process if possible (only if the app was killed in the bank code verification step, otherwise the dropIn closes automatically)
  8. Check for dropIn result, it should be UserCanceledException

Expected behavior

The DropIn process should retain and restore its state via SavedStateInstance (or equivalent method) and allow the user to complete the payment process even if the app is killed while in the background without returning UserCanceledException.

Screenshots

Step 2 - start drop in:

image

Step 3 - go to code confirmation screen:

image

Step 4 - put app in the background by pressing home button

Step 5 - kill the app as if the system did it: image

Step 6 - Return to the app

Step 7 - Complete payment process if possible

Step 8 - check that UserCanceledException is returned: image

matteo-goghero-leitha commented 8 months ago

Hi, any updates on this? Thank you

sshropshire commented 7 months ago

Hi @matteo-goghero-leitha thanks for filing this bug. Unfortunately for the 3DS library we use at the moment doesn't support process kill fully. It's something we've brought up and we hope it gets prioritized in the near future.