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
64 stars 126 forks source link

Update cardinal #131

Closed nicolobozzato closed 1 year ago

nicolobozzato commented 1 year ago

This is linked to the problem https://github.com/pikaju/flutter-braintree/issues/129 To use in my implementation I had to fork and rewrite the android part of the package, and I built it over my previous PR for 3ds implementation. I also change the readme cause it is necessary to change the class to switch browser windows to not cause a crash with PayPal

Though I'm not an expert on IOS and as there is still no problem with Cardinal on IOS I didn't write the IOS plugin part.

andrea689 commented 1 year ago

@nicolobozzato thanks for your work.

I tried using your PR, but after entering the CVV the app crashes with this error:

W/ActivityThread(16120): handleWindowVisibility: no activity for token android.os.BinderProxy@a98e17f
V/ActivityThread(16120): callActivityOnCreate
D/ActivityThread(16120): add activity client record, r= ActivityRecord{e3e9035 token=android.os.BinderProxy@a98e17f {com.threebee.threebee_flutter.dev/com.braintreepayments.api.ThreeDSecureActivity}} token= android.os.BinderProxy@a98e17f
I/BlockMonitor(16120): dispatchingThrewException In MainThread
D/AndroidRuntime(16120): Shutting down VM
I/QarthLog(16120): [PatchStore] createDisableExceptionQarthFile
I/QarthLog(16120): [PatchStore] create disable file for com.threebee.threebee_flutter.dev uid is 10320
E/AndroidRuntime(16120): FATAL EXCEPTION: main
E/AndroidRuntime(16120): Process: com.threebee.threebee_flutter.dev, PID: 16120
E/AndroidRuntime(16120): java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
E/AndroidRuntime(16120):    at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:853)
E/AndroidRuntime(16120):    at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:816)
E/AndroidRuntime(16120):    at androidx.appcompat.app.AppCompatDelegateImpl.onPostCreate(AppCompatDelegateImpl.java:537)
E/AndroidRuntime(16120):    at androidx.appcompat.app.AppCompatActivity.onPostCreate(AppCompatActivity.java:151)
E/AndroidRuntime(16120):    at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1387)
E/AndroidRuntime(16120):    at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3833)
E/AndroidRuntime(16120):    at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:235)
E/AndroidRuntime(16120):    at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:215)
E/AndroidRuntime(16120):    at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:187)
E/AndroidRuntime(16120):    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:105)
E/AndroidRuntime(16120):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2386)
E/AndroidRuntime(16120):    at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(16120):    at android.os.Looper.loop(Looper.java:213)
E/AndroidRuntime(16120):    at android.app.ActivityThread.main(ActivityThread.java:8178)
E/AndroidRuntime(16120):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(16120):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
E/AndroidRuntime(16120):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
I/Process (16120): Sending signal. PID: 16120 SIG: 9
Lost connection to device.

Do you have any ideas on how I can solve it?

andrea689 commented 1 year ago

@nicolobozzato I noticed now that the readme has been updated.

I replaced BraintreeBrowserSwitchActivity with DropInActivity, but I still getting the same error.

andrea689 commented 1 year ago

@nicolobozzato updating to com.braintreepayments.api:drop-in:6.8.0 solved it.

This is the braintree issue: https://github.com/braintree/braintree-android-drop-in/issues/326

nicolobozzato commented 1 year ago

@nicolobozzato updating to com.braintreepayments.api:drop-in:6.8.0 solved it.

This is the braintree issue: braintree/braintree-android-drop-in#326

Sorry for the late, glad it works with the new version. I think with the previous one it should work by adding the theme to the ThreeDSecureActivity. It seems that new version just implement it by default

<activity android:name="com.braintreepayments.api.ThreeDSecureActivity" android:theme="@style/Theme.AppCompat.Light" android:exported="true"> </activity>

I updated the readme to include it

pikaju commented 1 year ago

Hey @nicolobozzato, thank you for helping out! Can you please resolve the merge conflicts and also remove the .dart_tool folder (which shouldn't be in Git as far as I know)? Then I can merge and publish a new version.

nicolobozzato commented 1 year ago

@pikaju I'll try to do ASAP today or tomorrow at most

nicolobozzato commented 1 year ago

Hello @pikaju and all the ones interested. I made the change requested in my PR

VERY important there is currently a bug with the paypal tokenization. It goes in a constant loop that seems related to this bug. https://github.com/braintree/braintree_android/issues/557

As soon as I start the listener it gives me a user-canceled exception. I couldn't find a solution tonight. So I'm hesitant to put the PR ready for review. Maybe @pikaju you can give it a try, or I will try it tomorrow again. Also, the rest of the changing in BraintreeCustom was quite important, so please @pikaju give also a look at my choices.

nicolobozzato commented 1 year ago

I'm keeping working on it in the time I succeed to have. In addition to the problem mentioned above I have problem with the intent filter that handles the deep link when I come back to the app after I leave it for the webview. With the drop In I managed it with DropInActivity and is all good. But with the tokenization of PayPal DropInActivity cause a crash. There should be an alternative class to put in the manifest. So to be clear the DropIn Part seems working without problem now the problem is on the custom / tokenization part.

vkozinec commented 1 year ago

@nicolobozzato we forked this and applied to staging and seems that DropIn part works for both credit cards and google pay, we didn't have any issues with payments, just letting you know. Thx for the work, hopefully this will be merged soon so we can point directly to this lib instead of fork.

vkozinec commented 1 year ago

Any updates on this being merged? Thank you.

pikaju commented 1 year ago

Okay since this has been an open issue for a while now I will merge and publish a WIP state for anyone that doesn't need the custom PayPal stuff. Thank you for the immense effort, @nicolobozzato!

pikaju commented 1 year ago

(Now published as 4.0.0-dev.1)