stripe / stripe-android

Stripe Android SDK
https://stripe.com/docs/mobile/android
MIT License
1.27k stars 644 forks source link

Redirect to Banking App install page in iDEAL flow #2945

Closed utwyko closed 3 years ago

utwyko commented 3 years ago

Summary

The iDEAL flow currently only works if you have a banking app installed. If not, after clicking on the "Go to mobile banking app" the Android app receives a cancelled PaymentIntentResult. I'd expect it to instead open the Play Store or web page where the banking app can be installed.

Code to reproduce

  1. Create an iDEAL PaymentIntent with a bank for which you do not have the mobile app installed (e.g. regiobank)
  2. Pass the ConfirmPaymentIntentParams to Stripe.confirmPayment().
  3. Click on "Betalen met Mobiel Bankieren" (this means "Pay with Banking App")
  4. onActivityResult of the source app is called. After passing the intent to Stripe.onPaymentResult() the onSuccess callback is invoked with a PaymentIntentResult.outcome of 3 (CANCELED)

Recording of the failed flow in our app. We handle the cancelled outcome by showing a retryable dialog. reproduction

Android version

Tested on 8.0 and 11

Impacted devices

Tested on both real device (Galaxy s8) and emulators.

Installation method

Gradle dependency.

SDK version

16.0.1

mshafrir-stripe commented 3 years ago

@utwyko thanks for filing. Can you run adb logcat -s StripeSdk while you're attempting authentication and share the logs?

utwyko commented 3 years ago

@utwyko thanks for filing. Can you run adb logcat -s StripeSdk while you're attempting authentication and share the logs?

Of course, thanks for the quick response.

10-20 15:24:08.197 21324 21451 I StripeSdk: Event: stripe_android.payment_intent_confirmation
10-20 15:24:08.207 21324 21451 I StripeSdk: POST https://api.stripe.com/v1/payment_intents/pi_1HeKovHSF88ic3ySqazAJUUI/confirm
10-20 15:24:09.468 21324 21451 I StripeSdk: Request-Id: req_dQFIistBWZ2G21, Status Code: 200
10-20 15:24:09.493 21324 21324 I StripeSdk: Event: stripe_android.url_redirect_next_action
10-20 15:24:09.493 21324 21324 D StripeSdk: PaymentAuthWebViewStarter#start()
10-20 15:24:09.735 21324 21324 D StripeSdk: PaymentAuthWebViewActivity#onCreate()
10-20 15:24:09.958 21324 21324 D StripeSdk: PaymentAuthWebViewActivity#customizeToolbar()
10-20 15:24:09.961 21324 21324 D StripeSdk: PaymentAuthWebViewActivity#onCreate() - PaymentAuthWebView init and loadUrl
10-20 15:24:10.231 21324 21324 D StripeSdk: PaymentAuthWebViewActivity#onCreateOptionsMenu()
10-20 15:24:10.402 21324 21324 D StripeSdk: PaymentAuthWebViewClient#shouldOverrideUrlLoading(WebResourceRequest)
10-20 15:24:10.402 21324 21324 D StripeSdk: PaymentAuthWebViewClient#shouldOverrideUrlLoading() - https://hooks.stripe.com/adapter/ideal/redirect?amount=250&client_secret=<REDACTED>&currency=eur&livemode=true&return_url=https%3A%2F%2Fhooks.stripe.com%2Fredirect%2Fcomplete%2F<REDACTED>%3Fclient_secret%3D<REDACTED>&source=src_1HeKowHSF88ic3ySax6yviVg&usage=single_use
10-20 15:24:10.402 21324 21324 D StripeSdk: PaymentAuthWebViewClient#updateCompletionUrl()
10-20 15:24:10.402 21324 21324 D StripeSdk: PaymentAuthWebViewClient#isReturnUrl()
10-20 15:24:10.670 21324 21324 D StripeSdk: PaymentAuthWebViewClient#shouldOverrideUrlLoading(WebResourceRequest)
10-20 15:24:10.670 21324 21324 D StripeSdk: PaymentAuthWebViewClient#shouldOverrideUrlLoading() - https://r.girogate.de/pi/t1idealacquiring?tx=452785280&rs=SIxByiNZzyGXlXLI1AspPP0bz7gtFxnN&cs=c11289f57130d7ce77bcef28b5518587ca71b3889516eefe5a5ba94b54a60ce7
10-20 15:24:10.670 21324 21324 D StripeSdk: PaymentAuthWebViewClient#updateCompletionUrl()
10-20 15:24:10.670 21324 21324 D StripeSdk: PaymentAuthWebViewClient#isReturnUrl()
10-20 15:24:10.931 21324 21324 D StripeSdk: PaymentAuthWebViewClient#shouldOverrideUrlLoading(WebResourceRequest)
10-20 15:24:10.931 21324 21324 D StripeSdk: PaymentAuthWebViewClient#shouldOverrideUrlLoading() - https://diensten.regiobank.nl/online/ideal/sign?sp=t1nKuwXq7ahzhIWbqtYQ0qEeDoNEloWD9ohpg2JhBVz0Mib1rNBu&trxid=0140000030733824
10-20 15:24:10.931 21324 21324 D StripeSdk: PaymentAuthWebViewClient#updateCompletionUrl()
10-20 15:24:10.931 21324 21324 D StripeSdk: PaymentAuthWebViewClient#isReturnUrl()
10-20 15:24:11.104 21324 21324 D StripeSdk: PaymentAuthWebViewClient#shouldOverrideUrlLoading(WebResourceRequest)
10-20 15:24:11.104 21324 21324 D StripeSdk: PaymentAuthWebViewClient#shouldOverrideUrlLoading() - https://diensten.regiobank.nl/online/ideal/#/sign?sp=t1nKuwXq7ahzhIWbqtYQ0qEeDoNEloWD9ohpg2JhBVz0Mib1rNBu&trxid=0140000030733824
10-20 15:24:11.104 21324 21324 D StripeSdk: PaymentAuthWebViewClient#updateCompletionUrl()
10-20 15:24:11.104 21324 21324 D StripeSdk: PaymentAuthWebViewClient#isReturnUrl()
10-20 15:24:13.597 21324 21324 D StripeSdk: PaymentAuthWebViewClient#onPageFinished() - https://diensten.regiobank.nl/online/ideal/#/sign?sp=t1nKuwXq7ahzhIWbqtYQ0qEeDoNEloWD9ohpg2JhBVz0Mib1rNBu&trxid=0140000030733824
10-20 15:24:13.598 21324 21324 D StripeSdk: PaymentAuthWebViewClient#hideProgressBar()
10-20 15:24:16.072 21324 21324 D StripeSdk: PaymentAuthWebViewClient#shouldOverrideUrlLoading(WebResourceRequest)
10-20 15:24:16.072 21324 21324 D StripeSdk: PaymentAuthWebViewClient#shouldOverrideUrlLoading() - nl-regiobank-ideal://payment?trxid=0140000030733824&sp=t1nKuwXq7ahzhIWbqtYQ0qEeDoNEloWD9ohpg2JhBVz0Mib1rNBu
10-20 15:24:16.072 21324 21324 D StripeSdk: PaymentAuthWebViewClient#updateCompletionUrl()
10-20 15:24:16.072 21324 21324 D StripeSdk: PaymentAuthWebViewClient#isReturnUrl()
10-20 15:24:16.072 21324 21324 D StripeSdk: PaymentAuthWebViewClient#openIntent()
10-20 15:24:16.076 21324 21324 D StripeSdk: PaymentAuthWebViewClient#onAuthCompleted()
10-20 15:24:16.168 21324 21451 I StripeSdk: Event: stripe_android.payment_intent_retrieval
10-20 15:24:16.168 21324 21451 I StripeSdk: GET https://api.stripe.com/v1/payment_intents/pi_1HeKovHSF88ic3ySqazAJUUI
10-20 15:24:16.447 21324 21451 I StripeSdk: Request-Id: req_d972r4bF3QCFmT, Status Code: 200
10-20 15:24:16.449 21324 21324 D StripeSdk: Dispatching PaymentIntentResult for pi_1HeKovHSF88ic3ySqazAJUUI
mshafrir-stripe commented 3 years ago

To clarify the expected behavior:

If the banking app is not installed, are you expecting to be directed to authenticate the transaction in a WebView (and you aren't seeing that)?

utwyko commented 3 years ago

To clarify the expected behavior:

If the banking app is not installed, are you expecting to be directed to authenticate the transaction in a WebView (and you aren't seeing that)?

When I opened this ticket I expected the install page (either Play Store or a custom page) to be opened. Looking at the logs, I realise that that's up to the individual bank to handle.

In this example, nl-regiobank-ideal://payment is requested and cannot be handled by any installed apps. From Stripe's perspective I'd expect nothing to happen and the Secure Checkout webview to remain open. That way the user can still click on the "Betalen met internet bankieren" (Pay with web banking). And the bank itself can improve the deeplink to the mobile app to redirect to the Play Store if the app is not installed (not 100% sure if that's allowed in such an embedded webview though).

One other option that could work is to get a specific result outcome from Stripe so we can show our own dialog (e.g. "You've chosen to pay with the bank app but it's not installed, please install it first and try again").

mshafrir-stripe commented 3 years ago

We just released 16.7.1, which adds support for authenticating 3DS1 in Custom Tabs instead of a WebView. I believe this will fix the issues described here.

Please refer to the release notes and the Stripe#confirmPayment() documentation for more details.

mshafrir-stripe commented 3 years ago

Please re-open if you're still having issues after upgrading. If you're setting a custom return_url you'll need to remove it.