Closed amentone closed 3 years ago
When stripeSdk.initialise() is invoked, stripeSdk property has not yet initialized.
com/flutter/stripe/StripeAndroidPlugin.kt
44 when (call.method) { 45 "initialise" -> { 46 stripeSdk.initialise( 47 params = ReadableMap(call.arguments as JSONObject), 48 promise = Promise(result), 49 ) 50 }
And this is strange because the initialization is made here:
com/flutter/stripe/StripeAndroidPlugin.kt
107 override fun onAttachedToActivity(binding: ActivityPluginBinding) { 108 stripeSdk = StripeSdkModule(ReactApplicationContext(binding), stripeSdkCardViewManager) 109 }
Is possibile that onAttachedToActivity is never triggered? Unfortunately I can't set breakpoints there, I tried with logging but nothing appear on the debug console.
Is your main activity based on FlutterFragmentActivity or FlutterActivity?
Sorry for my question, maybe I am not prepared for this. I'm using your plugin in a flutter application. FlutterActivity/FlutterFragmentAcitivity are useful to integrate Flutter within an Android app, is that my case? I have not written any main activity.
Thank you for your support, and sorry, I am trying to learn :)
Noo need to worry! Thank you for creating this issue, you have been very helpful so far. By default, Flutter apps use FlutterActivity
by default. You can find this in the file MainActivity.kt
inside the android folder.
I think FlutterFragmentActivity is needed for the Stripe SDK to work, @jonasbark can you confirm this?. If this is the case we should add this to the docs.
The change should be quite easy, change FlutterActivity
to FlutterFragmentAcitivity
in MainActivity.kt
Ah ok! Thanks for this tip. I did a quick check and yes, my MainActivity is based on FlutterActivity while the MainActivity (from the example, that works) is based on FlutterFragmentActivity but I missed totally this thing.
Now it's working well.
Thank you guys!
Hi, I have the same error, but changing my MainActivity.kt I receive errors from Firebase plugin!
Have you suggestion to solve this? There is another fix ?
Thanks
Could you specify the error you are getting with the Firebase plugin?
Could you specify the error you are getting with the Firebase plugin?
It's work now, I cleaned the project!
I will close this issue now that is detailed inside the readme
I'll implement a runtime check so it's easier to read configuration issues
Hi guys, I'm back here writing again.
I'm developing a plugin for flutter to insert card payment functionality inside my flutter app for mypos using mypos SDK (myPOS-Smart-SDK).
My app is about "digital commercial documents" (receipt) and is used by vendors instead of a physical cash register.
I only use stripe for subscription renewal, which is required to use some services in the app.
So these two plugins are always used separately but I'm having some unexpected issues.
The functioning of the app is like a simple cash register, when there is a sale there is a request for payment and the customer can decide to pay by card using the integrated card reader of mypos. The payment handling is done with the plugin I'm developing that consumes the mypos API internally.
The strange thing is that when the payment finishes and mypos close its activity, the app crashes throwing me this exception:
This left me surprised as I am not using Stripe in this segment.
Seeing the message error, I actually tried using stripe before I could make a payment with the mypos API, and it went like this... After making the payment I get a black screen but the app doesn't crash and this is the error message:
I emphasize that Stripe has nothing to do with these payments. I use it elsewhere to be able to renew the subscription which allows you to use premium features.
I'm trying to go deeper but I can't understand the problem. If you have any ideas I would be very grateful. Thank you!
This already provides plenty of information, thank you! We will have a look.
I followed the example in order to do payments with webook and I believe I have not missed anything. When I call confirmPaymentMethod:
I get this error:
Log error
```E/MethodChannel#flutter.stripe/payments( 9694): Failed to handle method call E/MethodChannel#flutter.stripe/payments( 9694): kotlin.UninitializedPropertyAccessException: lateinit property stripeSdk has not been initialized E/MethodChannel#flutter.stripe/payments( 9694): at com.flutter.stripe.StripeAndroidPlugin.onMethodCall(StripeAndroidPlugin.kt:44) E/MethodChannel#flutter.stripe/payments( 9694): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233) E/MethodChannel#flutter.stripe/payments( 9694): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85) E/MethodChannel#flutter.stripe/payments( 9694): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818) E/MethodChannel#flutter.stripe/payments( 9694): at android.os.MessageQueue.nativePollOnce(Native Method) E/MethodChannel#flutter.stripe/payments( 9694): at android.os.MessageQueue.next(MessageQueue.java:363) E/MethodChannel#flutter.stripe/payments( 9694): at android.os.Looper.loop(Looper.java:173) E/MethodChannel#flutter.stripe/payments( 9694): at android.app.ActivityThread.main(ActivityThread.java:8178) E/MethodChannel#flutter.stripe/payments( 9694): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#flutter.stripe/payments( 9694): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) E/MethodChannel#flutter.stripe/payments( 9694): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101) E/flutter ( 9694): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: PlatformException(error, lateinit property stripeSdk has not been initialized, null, kotlin.UninitializedPropertyAccessException: lateinit property stripeSdk has not been initialized E/flutter ( 9694): at com.flutter.stripe.StripeAndroidPlugin.onMethodCall(StripeAndroidPlugin.kt:44) E/flutter ( 9694): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233) E/flutter ( 9694): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85) E/flutter ( 9694): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818) E/flutter ( 9694): at android.os.MessageQueue.nativePollOnce(Native Method) E/flutter ( 9694): at android.os.MessageQueue.next(MessageQueue.java:363) E/flutter ( 9694): at android.os.Looper.loop(Looper.java:173) E/flutter ( 9694): at android.app.ActivityThread.main(ActivityThread.java:8178) E/flutter ( 9694): at java.lang.reflect.Method.invoke(Native Method) E/flutter ( 9694): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) E/flutter ( 9694): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101) E/flutter ( 9694): ) E/flutter ( 9694): #0 JSONMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:164:7) E/flutter ( 9694): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18) E/flutter ( 9694):The thing is that the example works, my app doesn't. I've call also in my main.dart before runApp and public key already configured:
flutter doctor -v
``` [✓] Flutter (Channel stable, 2.2.0, on Linux, locale en_GB.UTF-8) • Flutter version 2.2.0 at /home/anmentone/lib/flutter • Framework revision b22742018b (10 days ago), 2021-05-14 19:12:57 -0700 • Engine revision a9d88a4d18 • Dart version 2.13.0 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /home/anmentone/Android/Sdk • Platform android-30, build-tools 30.0.3 • Java binary at: /usr/local/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 11.0.8+0-b944-P17168821) • All Android licenses accepted. [✓] Chrome - develop for the web • Chrome at google-chrome [✓] Android Studio (version 4.2) • Android Studio at /usr/local/android-studio • Flutter plugin version 56.0.2 • Dart plugin version 202.8488 • Java version OpenJDK Runtime Environment (build 11.0.8+0-b944-P17168821) [✓] IntelliJ IDEA Community Edition (version 2021.1) • IntelliJ at /usr/local/idea-IC-211.7142.45 • Flutter plugin version 56.0.5 • Dart plugin version 211.7233 [✓] VS Code (version 1.56.2) • VS Code at /usr/share/code • Flutter extension version 3.22.0 [✓] Connected device (2 available) • POT LX1 (mobile) • 39V4C19A18025168 • android-arm64 • Android 10 (API 29) • Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.212 • No issues found! ```Thanks for your help!