pikaju / flutter-braintree

Flutter plugin that wraps the native Braintree SDKs. Enables payments with credit cards, PayPal, Google Pay and more.
https://pub.dev/packages/flutter_braintree
MIT License
66 stars 129 forks source link

App Crashes on Cancel or after payment #176

Open CastanetLaurentiu opened 1 month ago

CastanetLaurentiu commented 1 month ago

I am trying to implement the braintree flow in my app and it seems to work until I click "Cancel and return to.." or I go through the entire payment process and crashes when it has to return to the app.

This is the error I get

E/AndroidRuntime(11837): FATAL EXCEPTION: main E/AndroidRuntime(11837): Process: net.castanet.app, PID: 11837 E/AndroidRuntime(11837): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.castanet.app/com.braintreepayments.api.DropInActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.os.Bundle.setClassLoader(java.lang.ClassLoader)' on a null object reference E/AndroidRuntime(11837): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3645) E/AndroidRuntime(11837): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3782) E/AndroidRuntime(11837): at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101) E/AndroidRuntime(11837): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) E/AndroidRuntime(11837): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) E/AndroidRuntime(11837): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307) E/AndroidRuntime(11837): at android.os.Handler.dispatchMessage(Handler.java:106) E/AndroidRuntime(11837): at android.os.Looper.loopOnce(Looper.java:201) E/AndroidRuntime(11837): at android.os.Looper.loop(Looper.java:288) E/AndroidRuntime(11837): at android.app.ActivityThread.main(ActivityThread.java:7872) E/AndroidRuntime(11837): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(11837): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) E/AndroidRuntime(11837): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) E/AndroidRuntime(11837): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.os.Bundle.setClassLoader(java.lang.ClassLoader)' on a null object reference E/AndroidRuntime(11837): at com.braintreepayments.api.DropInActivity.getDropInRequest(DropInActivity.java:124) E/AndroidRuntime(11837): at com.braintreepayments.api.DropInActivity.onCreate(DropInActivity.java:78) E/AndroidRuntime(11837): at android.app.Activity.performCreate(Activity.java:8305) E/AndroidRuntime(11837): at android.app.Activity.performCreate(Activity.java:8284) E/AndroidRuntime(11837): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417) E/AndroidRuntime(11837): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3626) E/AndroidRuntime(11837): ... 12 more I/Process (11837): Sending signal. PID: 11837 SIG: 9 Lost connection to device.

Exited.

This is my android manifest

And this is the function for triggering the payment process

void startPayPalPayment(price, message, token) async { final request = BraintreeDropInRequest( clientToken: token, collectDeviceData: true, paypalRequest: BraintreePayPalRequest( amount: price, displayName: 'Castanet', ), ); BraintreeDropInResult? result = await BraintreeDropIn.start(request); if (result != null) { print('Nonce: ${result.paymentMethodNonce.nonce}'); } else { print('Selection was canceled.'); } }

Any help is much appreciated.

BunnyBuddy commented 1 month ago

Is it just on a particular android version ? Have you tried to run it on different android versions?

CastanetLaurentiu commented 1 month ago

I tried it on 2 real devices (S23FE and A13) and 3 or 4 different emulators. It behaves the same on all of them.

Is working fine on iOS, on issues whatsoever.

BunnyBuddy commented 3 weeks ago

I tried it on 2 real devices (S23FE and A13) and 3 or 4 different emulators. It behaves the same on all of them.

Is working fine on iOS, on issues whatsoever.

Try this on a device/emulator other than Samsung (it seems to happen on Samsung devices only). I have hit the same issue on Samsung S21FE

CastanetLaurentiu commented 3 weeks ago

Well, I tested it out on Google pixel 6 and 4 emulators and does the same thing. I don't think that it's a Samsung only problem, and even if it is when half of the android devices are Samsung ....

Devices I tested it on are: Emulators:

Real Devices

iOS Simulator

Working on iOS crashing on Android.

BunnyBuddy commented 3 weeks ago

Yeah I see that especially on Android 14. I don't know why Braintree has no comments on this issue. I have tagged their devs multiple times and they haven't responded yet as to why this is happening and if there's a solution.

CastanetLaurentiu commented 3 weeks ago

Thank you. I gave up on this for now and implemented a different payment solution, away from paypal and braintree. I might give it another try if an update is released.