Skip to content

Back Button Navigation Issue with Stripe Payment Gateway in Flutter #1822

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

Closed
SeemanthWebcastle opened this issue Jun 26, 2024 · 8 comments
Closed
Labels
Awaiting response Awaiting response from the issuer needs triage Needs triage

Comments

@SeemanthWebcastle
Copy link

I am a Flutter developer integrating Stripe payment gateway into my Flutter application. Following the documentation, I switched from using FlutterActivity to FlutterFragmentActivity in MainActivity.kt. After making this change, the back button functionality in my app stopped working as expected.

Steps to Reproduce:

  1. Modify MainActivity.kt to extend FlutterFragmentActivity instead of FlutterActivity.
  2. Build and run the Flutter app.
  3. Navigate to a screen where Stripe payment is implemented.
  4. Attempt to navigate back using the device's hardware back button.

Expected Behavior:
When pressing the back button, the app should navigate back to the previous screen within the app.

Actual Behavior:
After switching to FlutterFragmentActivity, pressing the back button navigates the app to the home screen of the device instead of navigating back within the app.

Additional Information:

  • Flutter version: 3.19.0
  • Stripe SDK version: ^10.1.1

Possible Cause:
The change to FlutterFragmentActivity may have affected the handling of back button events within the Flutter application, possibly due to differences in how FlutterFragmentActivity manages the Flutter view compared to FlutterActivity.

Thank you for your attention to this matter. Please let me know if you require further clarification or additional information to investigate and address this issue effectively.

@SeemanthWebcastle SeemanthWebcastle added the needs triage Needs triage label Jun 26, 2024
@jonasbark
Copy link
Member

"where Stripe payment is implemented"
can you clarify what you mean by that? Payment Sheet? CardField?

@Vikkybliz
Copy link

"where Stripe payment is implemented" can you clarify what you mean by that? Payment Sheet? CardField?

Back button closes app when using app instead of going to previous page.

@remonh87
Copy link
Member

remonh87 commented Jul 1, 2024

Can you provide a reproducible example here? because in my app the backbutton behavior works as expected. Same goes for the example app

@remonh87 remonh87 added the Awaiting response Awaiting response from the issuer label Jul 1, 2024
@shashikantdwivedi
Copy link

I am a Flutter developer integrating Stripe payment gateway into my Flutter application. Following the documentation, I switched from using FlutterActivity to FlutterFragmentActivity in MainActivity.kt. After making this change, the back button functionality in my app stopped working as expected.

Steps to Reproduce:

  1. Modify MainActivity.kt to extend FlutterFragmentActivity instead of FlutterActivity.
  2. Build and run the Flutter app.
  3. Navigate to a screen where Stripe payment is implemented.
  4. Attempt to navigate back using the device's hardware back button.

Expected Behavior: When pressing the back button, the app should navigate back to the previous screen within the app.

Actual Behavior: After switching to FlutterFragmentActivity, pressing the back button navigates the app to the home screen of the device instead of navigating back within the app.

Additional Information:

  • Flutter version: 3.19.0
  • Stripe SDK version: ^10.1.1

Possible Cause: The change to FlutterFragmentActivity may have affected the handling of back button events within the Flutter application, possibly due to differences in how FlutterFragmentActivity manages the Flutter view compared to FlutterActivity.

Thank you for your attention to this matter. Please let me know if you require further clarification or additional information to investigate and address this issue effectively.

I am facing the similar issue. Back button is closing the app after integrating stripe

@shashikantdwivedi
Copy link

I tried solving the issues. This issue is related to issue/related to predictive back not being supported. Here's a github issues which sums up the issue.

flutter/flutter#141564 (comment)

Also to resolve it. Here is a sample AndroidManifest.xml file -

<activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:enableOnBackInvokedCallback="false"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>


        </activity>
    Here, After adding this - android:enableOnBackInvokedCallback="false" in Activity solves the issues for me.

@SeemanthWebcastle
Copy link
Author

SeemanthWebcastle commented Jul 5, 2024 via email

@shashikantdwivedi
Copy link

shashikantdwivedi commented Jul 5, 2024 via email

@remonh87
Copy link
Member

This is not something we can change in our library. Stripe requires us to use the FlutterFragmentActivity so I would recommend if you experience problems with the backbutton to raise a ticket there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting response Awaiting response from the issuer needs triage Needs triage
Projects
None yet
Development

No branches or pull requests

5 participants