flutter-stripe / flutter_stripe

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

Uncaught Unsupported operation: Platform._operatingSystem when deployed to firebase hosting for web #1618

Open jeedy20 opened 5 months ago

jeedy20 commented 5 months ago

I get an Uncaught Unsupported operation: Platform._operatingSystem after i deploy my flutter web app to firebase hosting and its stucked in the splash screen any solution to this?. I think this is the cause of the error in my main.dart page. await dotenv.load(fileName: ".env"); Stripe.publishableKey = dotenv.env['StripePublishableKey']!; Stripe.merchantIdentifier = 'merchant.flutter.stripe.test'; Stripe.urlScheme = 'flutterstripe'; await Stripe.instance.applySettings();

jeffysmak commented 5 months ago

Getting same, any solution you found?

jeedy20 commented 5 months ago

Nothing yet

remonh87 commented 5 months ago

Can you fill in the required info of the issue? I need a full stacktrace + output of flutter doctor.

jeedy20 commented 5 months ago
Untitled

[√] Flutter (Channel stable, 3.16.9, on Microsoft Windows [Version 10.0.22000.2538], locale en-NG) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [√] Chrome - develop for the web [!] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.33) X The current Visual Studio installation is incomplete. Please use Visual Studio Installer to complete the installation or reinstall Visual Studio. [!] Android Studio (version 2021.3) X Unable to determine bundled Java version. [√] Android Studio (version 2023.1) [√] VS Code (version 1.85.2) [√] Connected device (4 available) [√] Network resources These are what you requested for

jeffysmak commented 5 months ago

i implemented this plugin's basic of functionality my self and full fill my requirements. with stripe js (client side) card-field element, tested on firebase works fine.

remonh87 commented 5 months ago

@jeedy20 I cannot see in the stack trace that it has to do something with our sdk. What kind of widget are you using ?

Vigneshb799 commented 5 months ago

@remonh87 i have also same problem.Platform._operatingSystem in flutter web [√] Flutter (Channel stable, 3.16.3, on Microsoft Windows [Version 10.0.22000.2538], locale en-NG) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [√] Chrome - develop for the web [!] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.33) X The current Visual Studio installation is incomplete. Please use Visual Studio Installer to complete the installation or reinstall Visual Studio. [!] Android Studio (version 2021.3) X Unable to determine bundled Java version. [√] Android Studio (version 2023.1) [√] VS Code (version 1.85.2) [√] Connected device (4 available) [√] Network resources

jeedy20 commented 5 months ago

@jeedy20 I cannot see in the stack trace that it has to do something with our sdk. What kind of widget are you using ?

Payment Element sir.

jonasbark commented 5 months ago

I was unable to reproduce this in the example app. Can you provide a small example repo / code?

richardnovasnw commented 5 months ago

I had been experiencing the same issue then realised that I forgot to add flutter_stripe_web: ^5.0.0 to the dependencies. flutter_stripe and flutter_stripe_web, both are required to work on flutter web.

This worked for me! Hope this helps someone.

jeffysmak commented 5 months ago

I had been experiencing the same issue then realised that I forgot to add flutter_stripe_web: ^5.0.0 to the dependencies. flutter_stripe and flutter_stripe_web, both are required to work on flutter web.

This worked for me! Hope this helps someone.

i added both dependencies flutter_stripe and flutter_stripe_web but not worked for me 🤨. it works fine in debug mode but when app deployed to firebase hosting than its not.

jeedy20 commented 4 months ago

Yeah. Any solution yet?

remonh87 commented 4 months ago

does the same happen when you run flutter run --release ?

asdico commented 4 months ago

@remonh87 I'm having the same issue, but as long as I'm working locally everything works. So, it doesn't happen the same when I run flutter run --release

remonh87 commented 4 months ago

I looked into it and this is a flutter issue and not something from this sdk: https://github.com/flutter/flutter/issues/36126

jeedy20 commented 4 months ago

So what could be the solution?

asdico commented 4 months ago

@jeedy20 I solved the issue upgrading both Flutter and the SDKs version.

flutter --version

Flutter 3.19.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision bae5e49bc2 (2 weeks ago) • 2024-02-13 17:46:18 -0800
Engine • revision 04817c99c9
Tools • Dart 3.3.0 • DevTools 2.31.1

Flutter SKDs version:

  flutter_stripe: ^10.0.0
  flutter_stripe_web: ^5.0.0

Try this out, it worked for me.

jeedy20 commented 4 months ago

Okay thanks alot

andrezanna commented 4 months ago

Since I can not upgrade to Flutter 3.19 I made an hacky edit in method_channel_stripe

StripePlatform create() => kIsWeb?MethodChannelStripe(
    methodChannel: const MethodChannel(
      'flutter.stripe/payments',
      JSONMethodCodec(),
    ),
    platformIsIos: false,
    platformIsAndroid: false,
  ):MethodChannelStripe(
        methodChannel: const MethodChannel(
          'flutter.stripe/payments',
          JSONMethodCodec(),
        ),
        platformIsIos: Platform.isIOS,
        platformIsAndroid: Platform.isAndroid,
      );
Nicola-Cestaro commented 2 weeks ago

I fixed this issue that for some reason only happened on the Web version on Android devices (iOS Web and Desktop Web was working fine)

With this

if(kIsWeb){ WebStripe.instance.initialise(publishableKey: "stripePublicKey"); } else { Stripe.publishableKey = "stripePublicKey"; }