Skip to content
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

[Android] 3DSecure confirmation screen closed if app is put in background #355

Closed
konstantinmv opened this issue Jun 18, 2021 · 41 comments · May be fixed by #1497
Closed

[Android] 3DSecure confirmation screen closed if app is put in background #355

konstantinmv opened this issue Jun 18, 2021 · 41 comments · May be fixed by #1497

Comments

@konstantinmv
Copy link

Hi all.
We currently have a bug happening on Android only.
After using confirmPaymentMethod on a payment, the 3DS screen is brought up. If instead of confirming / denying the payment on this screen we go into background and then bring the app back to active again, 3DS screen is just dismissed, so the app is stuck.
Obviously, at that moment Stripe payment is pending, but there's no way to bring up the payment screen again.
Even if there was, then the process would be repeated - if the user has to go to the bank's app in order to confirm the payment or whatever, the problem would come back and always be present.

Note: this does not happen on iOs.

To Reproduce
Steps to reproduce the behaviour:

  1. Boot Android React Native app.
  2. Confirm payment with a 3DS card.
  3. When the hooks.stripe.com screen with the confirmation gets brought up, go into background.
  4. Wait 2 seconds, open the app again.
  5. There you have a problem.

Expected behavior
The expected behaviour would be the same as in iOs, for this screen not to be dismissed until the user does some action upon it.

Desktop (please complete the following information):
OS: MacOs Big Sur 11.2.3
Browser: Chrome
Version: 91.0.4472.77 (Official Build) (x86_64)

Smartphone (please complete the following information):
Device: Honor 9 Lite
Android version: 9

Additional context
Stripe version: 0.1.4
React native version: 0.63.4

Thanks in advance!

@thorsten-stripe thorsten-stripe added this to Inbound support questions in React Native V1 backlog Jun 23, 2021
@thorsten-stripe thorsten-stripe added need triage question Further information is requested labels Jun 24, 2021
@thorsten-stripe
Copy link
Contributor

@michelleb-stripe can you look into this?

@vipu-sa
Copy link

vipu-sa commented Jun 25, 2021

React Native Android - The previous state of stripe payment screen not getting When app reopens click of app icon after minimize.
when I am performing 3d secure payment using stripe payment screen.When I minimize the application in between this process and, reopen it by clicking on the app icon at that time I am not getting the previous state of stripe payment screen specific for android.

@aanalmehta-sa
Copy link

We are facing the same issue. By when we can expect this issue to be resolved?
We are having a major bug because of this.

@michelleb-stripe
Copy link
Contributor

@aanalmehta-sa and @vipu-sa and @konstantinmv

In your manifest file you will have a single activity that has an intent filter of category: android.intent.category.LAUNCHER similar to:

      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

Can you post the launchMode set on this activity? I believe this might be an issue with a launchMode = singleTask. If you use the defaultLaunch mode it might work. (See related issue: stripe/stripe-android#3290).

@arekkubaczkowski
Copy link
Collaborator

closing due to inactivity, @aanalmehta-sa @vipu-sa @konstantinmv please reopen if above solution didn't work for you

@arekkubaczkowski arekkubaczkowski moved this from Inbound support questions to Payment methods backlog in React Native V1 backlog Jul 26, 2021
@arekkubaczkowski arekkubaczkowski moved this from Payment methods backlog to Done in React Native V1 backlog Jul 26, 2021
@cristeahub
Copy link

cristeahub commented Aug 9, 2021

closing due to inactivity, @aanalmehta-sa @vipu-sa @konstantinmv please reopen if above solution didn't work for you

@arekkubaczkowski I want to draw attention to stripe/stripe-android#3290 also being closed pointing here, while the issue is still real for users like myself. Please reconsider reopening again.

Can you post the launchMode set on this activity? I believe this might be an issue with a launchMode = singleTask. If you use the defaultLaunch mode it might work. (See related issue: stripe/stripe-android#3290).

@michelleb-stripe I have this issue and I am using launchMode="singleTask". My current React Native app will not work if I change my launchMode, I am unable to use defaultLaunch. Can I provide you with some more information to help you debug this?

@aaronSig
Copy link

I'm having the same issue.

To recreate:

  • Initiate payment
  • Leave the app to check for a 3D secure SMS.
  • Re-open the app by clicking on the app icon on the home screen

The payment errors out with "Failed to retrieve a PaymentSheetResult".

However, if you instead resume the app from the Android Task Switcher everything works as expected.

My manifest looks like:

<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
    android:launchMode="singleTask"
    android:windowSoftInputMode="adjustResize">
    
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="myapp" />
    </intent-filter>	
</activity>

I believe you're right that changing the singleTask launch mode will fix but this breaks deep linking for our RN Android app.

Would there be another work around?

@michelleb-stripe michelleb-stripe self-assigned this Sep 18, 2021
@bob-user
Copy link

bob-user commented Oct 11, 2021

Also facing this issue on Android only (same reproduction as @aaronSig), with the following environment :

  • expo: 42.0.0
  • react-native: 0.63.4
  • @stripe/stripe-react-native: 0.1.4

However, resuming the app with the task switcher working as expected (tested in expo go and standalone build).

@bob-user
Copy link

@arekkubaczkowski @michelleb-stripe is there anything new about this issue ?

@michelleb-stripe
Copy link
Contributor

@bob-user and @konstantinmv @aaronSig @cristeahub

3DS has a challenge response, so there is no way for us to re-create the webview as it would re-trigger the challenge, the user would reopen the banking app, and have the same problem. As long as the activity with the webview still exists in somewhere in the task stack it should be possible to reopen it.

When you relaunch your app in this way, is onNewIntent being called or is it creating a new instance?

@michelleb-stripe
Copy link
Contributor

@bob-user and @konstantinmv @aaronSig @cristeahub

In order for this to work I believe the StripeBrowserLauncherActivity (in the case of 3DS1) needs to be somewhere on the task stack after the launcher is pressed. However, when I created an application with the launchMode set to "singleTask" the StripeBrowserLauncherActivity is destroyed when clicking the launcher. (I verified this by registering an ActivityLifecycleCallbacks in an Application.onCreate method and logging all lifecycle events).

If you can instead use singleTop, and in the onNewIntent method you can check if it is a deep link and do any work you need there?

@bob-user
Copy link

@michelleb-stripe I'm using the library in a managed expo app and I'm having trouble ejecting to access native code in order to test. Moreover, I'd like to keep up with the managed workflow so ejecting would only be a matter of debugging in my case. May this be resolved in an other way than accessing native code ?

@bob-user
Copy link

Same problem with the following config :

  • expo: 43.0.0
  • react-native: 0.64.2
  • @stripe/stripe-react-native: 0.2.2

shouldn't this issue be reopened ?

@RubenGuerrero
Copy link

Same problem here with the following config (managed flow expo app):

  • expo: 42.0.3
  • react-native: 0.63.4
  • @stripe/stripe-react-native: 0.1.4

Do you have any eta to solve this issue?

@michelleb-stripe
Copy link
Contributor

@acomley-stripe @trag-stripe Can you help engage with the expo team on this particular issue? I am happy to help jump in a conversation if needed.

@tautvilas
Copy link

tautvilas commented Dec 14, 2021

I am experiencing same issue. If launchMode is not singleTask resuming app from app icon works. However we can not use other launch mode with react-native because it might introduce other issues. Also when returning back to the app from the app switcher works, but if app is resumed from the app icon the 3Ds confirmation view is no more.

I have implemented launchMode="singleTop" for now and it seems that this launchMode does resolve the bug. So far I did not notice that this launchMode would impact my app in any negative way. In the long run I think the issue should be resolved on singleTask mode as well

@MagicMirouff
Copy link

Same issue here. 3DS process is killed when we resume app from home with appIcon ...
Any solution ?

@charliecruzan-stripe charliecruzan-stripe added P1 Address these issues second and removed need triage labels Feb 15, 2022
@viraj-nikam
Copy link

Is there any update on this bug? We are facing the same issue for android users.

@ottob
Copy link

ottob commented Jan 2, 2023

Same problem here on Android with the following config (managed flow expo app):

expo: 46.0.17
react-native: 0.69.6
@stripe/stripe-react-native: 0.13.1

@nicolasdevienne
Copy link

Same issue with presentPaymentSheet

@ottob
Copy link

ottob commented Mar 3, 2023

Hi, are you making any progress on this?

@charliecruzan-stripe
Copy link
Collaborator

The native version of the 3DS2 auth screen is on the roadmap and is the long term fix for this issue, but we're still looking into proper workarounds in the meantime

@huextrat
Copy link
Contributor

huextrat commented Apr 5, 2023

Hi @charliecruzan-stripe, any news regarding this issue ? It has always been there for 2 years and no solution is provided.

This is an issue affecting the 3DS confirmation on Android and causes unintended cases about payment, it's a bit annoying.

A workaround would be appreciable in next release until we get a real fix.

@charliecruzan-stripe
Copy link
Collaborator

Unfortunately we're still waiting on a fix in the stripe-android repo, I agree that this is pretty annoying and has been for a while. Let me check and see what the status of this fix is

@ottob
Copy link

ottob commented Apr 19, 2023

Friendly ping :)

@tgensol
Copy link
Collaborator

tgensol commented May 4, 2023

@charliecruzan-stripe any news ? (Can you give us the issue on stripe-android, thanks )

@tgensol
Copy link
Collaborator

tgensol commented Jun 2, 2023

@charliecruzan-stripe We made a quick fixed it on our own. Do you have any news ?

@ottob
Copy link

ottob commented Jun 12, 2023

We made a quick fixed it on our own.

@tgensol can you please share how you fixed it in your project?

@huextrat
Copy link
Contributor

huextrat commented Jun 12, 2023

Hi @ottob,

We tried to set up a workaround a few weeks ago. Here's what we have implemented:

  1. Catching "Failed to get PaymentResult from Intent" when an error is thrown
  2. If it's a match, we are trying to retrieve the paymentIntent or setupIntent with a 10sec delays by using: retrievePaymentIntent or retrieveSetupIntent
  3. If the status of the retrieved intent is now in Succeeded status, so we can continue our success flow

The 10sec delays is totally arbitrary for now.

Retrieving the intent therefore allows us to prevent some payment errors caused by "Failed to get PaymentResult from Intent", sometimes we still get errors after retrieving the intent like RequiresAction but for now I can't say whether this is normal or not.

In practice, this should work because the error occurs on the front end, but on the Stripe side the intent is in the right status if the user has validated the transaction on their bank.

This workaround can certainly be improved, but it gives you an idea of what we have tried to prevent this long life error. Don't hesitate to share if you see a way to improved it or even another workaround ;)

@charliecruzan-stripe It would be great to have an idea of the progression on this issue or at least to share the Android issue as you mentioned here : #355 (comment)

@gvestit
Copy link

gvestit commented Jul 2, 2023

Hi,

We have an web app but with the users using Android faced this issue. Something that we can do?

@huextrat
Copy link
Contributor

huextrat commented Aug 29, 2023

@charliecruzan-stripe @jaynewstrom-stripe @jameswoo-stripe any update on this issue ?

@stianjensen
Copy link

Hi guys! I think this is an issue that cannot really be solved by the Stripe library itself, as it has to do with the overall architecture of the Android app using it. Luckily, the fix should be quite straight-forward in a simple react-native app!

I found it when researching a similar issue in another part of our app where we display a Chrome custom tab in order to perform login authentication:
proyecto26/react-native-inappbrowser#213 (comment)

Basically, instead of just having one MainActivity where deeplink support requires you to give the MainActivity a launchMode of "singleTask", you split the application into two activites. One that is responsible for launching the app from the android launcher, and one that is then started by that 'launcher activity' and retains the singleTask launchmode.

I think the only thing Stripe can really do about this is to include this information in their documentation somehow, for users who need both deeplink support (for instance via Branch) and the option to use 3D secure via webviews.

@huextrat
Copy link
Contributor

Hi @stianjensen, thank you for this reply!

We've implemented it with a few adaptations for React Native while keeping deep links working properly, and it seems to work very well.

stianjensen added a commit to stianjensen/stripe-react-native that referenced this issue Sep 12, 2023
Using singleTask in an Android application for the activity that has an
intent-filter on the LAUNCHER, means that any activities running on top
of this activity will disappear when the app's icon is pressed again
from the launcher.

This is a problem, because when confirming a SetupIntent or
PaymentIntent, Stripe may need to present a web browser (its own
activity) for verification with a customer's bank or similar, and the
user may even need to leave this web browser activity temporarily to
navigate to their bank's own application. If the user is not careful
when navigating back to the original app, and taps the app's icon from
the launcher, the app will open to its original activity, and the web
browser is gone. Instead, the user will need to navigate back only using
Android's app switcher, which will correctly bring you back into the
open web browser activity.

The change in this commit side-steps this issue by splitting the example
application into two acitivites. One that is only responsible for
launching the application, and a second activity that actually
represents the react native application, and will be started by the
first activity, ensuring to only start it once.

This fixes stripe#355.
@zdnk
Copy link

zdnk commented Sep 19, 2023

Is there a way to achieve this in Expo managed workflow? or will you provide it as part of Stripe plugin for Expo?

@zdnk
Copy link

zdnk commented Sep 19, 2023

Here they have been trying to solve similar issue. They forced the web browser to NOT create a new task. Is this what might fix the issue? How can we force it?

@zdnk
Copy link

zdnk commented Oct 9, 2023

This is still a big issue for us using expo, anyone has a solution? We have many users failing the payment because of this issue.

@charliecruzan-stripe
Copy link
Collaborator

Added a note about this in our readme for now.

For expo users, you'll need access to native code for this so you might need to use a different Expo workflow that gives you that level of control

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.