flutter-stripe / flutter_stripe

Flutter SDK for Stripe.
https://pub.dev/packages/flutter_stripe
928 stars 514 forks source link

Google Pay Button Not Visible in Stripe Payment Sheet on Android Devices #1897

Closed mihiravdevs closed 2 weeks ago

mihiravdevs commented 3 weeks ago

Describe the bug I am integrating Stripe in a Flutter project using the flutter_stripe package (version 11.0.0). The Google Pay button is not appearing in the payment sheet on physical devices (Xiaomi Redmi Note 10 Pro Max and Realme 10) even though the Google Pay app is installed and functional on these devices.

To Reproduce Steps to reproduce the behavior:

  1. I have implemented flutter stripe payment sheet for subscription functionality, so when user click on subscribe payment sheet should open with google pay button

Expected behavior The Google Pay button should be visible in the Stripe payment sheet when Google Pay is available on the device.

Smartphone / tablet

Additional context Despite the correct setup and Google Pay being installed, the Google Pay button is not visible in the payment sheet on Android devices. I have verified that the Apple Pay button appears correctly on an iOS simulator. This issue persists even after uploading the app to the Play Store for internal testing.

Code Snippets:

  1. Flutter Stripe Initialization:

    
    void main() async {
    WidgetsFlutterBinding.ensureInitialized(); // Initialize Flutter Binding
    _initStripe();
    
    runApp(
    MultiProvider(
      providers: providers(),
      child: const MyApp(),
    ),
    );
    }

void _initStripe() async { Stripe.publishableKey = AppConstant.stripePublishKey; Stripe.merchantIdentifier = StringResources.appName; await Stripe.instance.applySettings(); }


2. Payment Sheet Setup:

Future makePayment({ required SubscriptionProvider provider, required String clientSecret, required String ephemeralKey, required String stripeUserID, }) async { provider.setLoading(true);

try { await Stripe.instance.initPaymentSheet( paymentSheetParameters: SetupPaymentSheetParameters( primaryButtonLabel: "Pay", customFlow: false, merchantDisplayName: StringResources.appName, setupIntentClientSecret: clientSecret, customerEphemeralKeySecret: ephemeralKey, applePay: const PaymentSheetApplePay( merchantCountryCode: 'CA', ), googlePay: PaymentSheetGooglePay( merchantCountryCode: 'CA', testEnv: true, // Set to false for production ), style: ThemeMode.system, ), );

await displayPaymentSheet(provider);

} on StripeException catch (e) { provider.setLoading(false); context.showSnackBar( 'Payment sheet initialization failed: ${e.error.localizedMessage}', type: SnackBarType.warning, ); } catch (e) { provider.setLoading(false); context.showSnackBar( 'An unexpected error occurred. Please try again.', type: SnackBarType.warning, ); } }


3. Android Manifest.xml

<meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true" />

mihiravdevs commented 3 weeks ago

I raised the same issue with the stipe support team, I am attaching the screenshot of reply

Screenshot 2024-08-20 at 6 31 26 PM
DavidEcclesPH commented 3 weeks ago

also experiencing this. further to your config above I have set the following in build.gradle as specified here https://developers.google.com/pay/api/android/guides/setup and https://docs.stripe.com/payments/accept-a-payment?platform=android&locale=en-GB : dependencies { implementation 'com.google.android.gms:play-services-wallet:19.4.0' implementation 'com.stripe:stripe-android:20.48.4' } but still seeing no googlepay button even in testEnv, same as @mihiravdevs

remonh87 commented 2 weeks ago

looks like potential dupliate of #1887

mihiravdevs commented 1 week ago

@remonh87 I think https://github.com/flutter-stripe/flutter_stripe/issues/1887 is different issue

Could you please guide what exactly I need to change to resolve the issue and make google pay button visible on my stripe payment sheet.