braintree / braintree-android-drop-in

Braintree Drop-In SDK for Android
https://developers.braintreepayments.com/guides/drop-in/android/v2
MIT License
124 stars 79 forks source link

Incompatibility with Flutter and Kotlin #169

Closed peternagy1332 closed 4 years ago

peternagy1332 commented 4 years ago

General information

Issue description

This is the third issue I'm opening in this topic, please forgive me if I'm not copypasting everything here too. In a nutshell, I'm experiencing an app crash when I dismiss the dropin in a freshly generated Flutter application with Kotlin as the main Android language.

As far as I know, currently there is no way to use Flutter+Kotlin+Braintree, that's why I consider this issue urgent.

Here are my issues: https://github.com/DeligenceTechnologies/Braintree-Payment-Gateway-for-Flutter/issues/25 https://github.com/Pikaju/FlutterBraintree/issues/12

flutter_braintree and braintree_payments are two separate plugins for Flutter and they are both suffering from this error. Also, they are referencing this native dropin plugin.

Here are the files files that call this plugin: https://github.com/Pikaju/FlutterBraintree/blob/master/android/src/main/java/com/example/flutter_braintree/FlutterBraintreeDropIn.java https://github.com/DeligenceTechnologies/Braintree-Payment-Gateway-for-Flutter/blob/master/android/src/main/java/com/deligence/braintree_payment/BraintreePaymentPlugin.java

I appreciate any help, but the best would be repository that demonstrates that either I'm wrong or there's indeed a bug.

scannillo commented 4 years ago

Hi. The errors referenced in the links you've sent are errors thrown by the Flutter wrapper SDK that you are using. Since that is a wrapper SDK not developed by us and not supported by us, we can't really help tracking down why that SDK is causing your app to crash.

If you have a stracktrace that points to our actual braintree_android or braintree-android-drop-in SDK, we could try our best to help.

peternagy1332 commented 4 years ago

@scannillo Hi. Thank you for your response. Now I had some time to dig a bit deeper into the problem. I've found out that the onActivityResult function is called twice in both wrapper SDKs and both of them was lacking a null check for the activeResult variable (second parameter of onMethodCall). I've created PRs for both SDKs that are containing just simple null checks as temporary solution (https://github.com/Pikaju/FlutterBraintree/pull/13 and https://github.com/DeligenceTechnologies/Braintree-Payment-Gateway-for-Flutter/pull/27). However , I still think that this problem originates from this SDK, since the onMethodCall function shouldn't be called twice.

scannillo commented 4 years ago

Hi. Glad you're working to resolve the issue with those PRs.

Like I said, we don't offer official Flutter support at the moment so your best bet is to continue troubleshooting with the wrapper SDK folks. We will update here if/when we do provide official Flutter support.

viper22223 commented 3 years ago

Please help me some one i dont know what need do C:\flutter.pub-cache\hosted\pub.dartlang.org\braintree_payment-1.2.4\android\src\main\java\com\deligence\braintree_payment\BraintreePaymentPlugin.java:104: error: cannot find symbol if(paymentNonce == null && paymentNonce.isEmpty()){ ^ symbol: method isEmpty() location: variable paymentNonce of type String 1 error

FAILURE: Build failed with an exception.

viper22223 commented 3 years ago

its plagin braintree payment

@Override public boolean onActivityResult(int requestCode, int resultCode, Intent data) { if(activeResult == null) return false; switch (requestCode) { case REQUEST_CODE: if (resultCode == Activity.RESULT_OK) { DropInResult result = data.getParcelableExtra(DropInResult.EXTRA_DROP_IN_RESULT); String paymentNonce = result.getPaymentMethodNonce().getNonce(); if(paymentNonce == null && paymentNonce.isEmpty()){ map.put("status", "fail"); map.put("message", "Payment Nonce is Empty."); activeResult.success(map); } else{ map.put("status", "success"); map.put("message", "Payment Nouce is ready."); map.put("paymentNonce", paymentNonce); activeResult.success(map); } } else if (resultCode == Activity.RESULT_CANCELED) { map.put("status", "fail"); map.put("message", "User canceled the Payment"); activeResult.success(map); } else { Exception error = (Exception) data.getSerializableExtra(DropInActivity.EXTRA_ERROR); map.put("status", "fail"); map.put("message", error.getMessage()); activeResult.success(map); } return true; default: return false; } }