Fitpassu / react-native-stripe-payments

Lightweight, easy to integrate and use React native library for Stripe payments (using Payment Intents) compliant with SCA (strong customer authentication)
MIT License
98 stars 30 forks source link

Can't use chrome debugger #20

Open DZuz14 opened 3 years ago

DZuz14 commented 3 years ago

I am getting an Invariant Violation any time I attempt to use the Debugger in React Native. This only occurred after I installed your package.

I looked in your source code and found some methods in the Java package that are synchronous.

After checking the lib/index.tsx file I saw that the StripePayments.init method gets invoked automatically when you use the setOptions method. I found that if I comment out the StripePayments.init line in the compiled JS code, my debugger then starts working properly.

Any advice? Thank you for the library.

Screenshot_1610056399

DZuz14 commented 3 years ago

More reading https://reactnative.dev/docs/native-modules-android#synchronous-methods

viktorasl commented 3 years ago

Hm, I should look deeper. I'm not quite familiar with react native architecture in such details.

EDIT: I see that there are two synchronous method. First one which you referenced initializes (sets up) Stripe SDK and as it could be called right before i.e payment I prefer it to be sync.

The second one is credit card validation. Will it cause problems for chrome debugger as well?

DZuz14 commented 3 years ago

@viktorasl I'm surprised other people haven't had a problem with this. What do you think about providing an async version of the setup method that returns a promise (I know it sounds kind of weird, but inherently everything that executes in the JS bridge is async, so it wouldn't be that weird)? In regards to the card validation, we don't use that part of the library, so it won't break the debugger, because we don't call that method.

viktorasl commented 3 years ago

The idea to have an async method looks valid. I'll look deeper into best practices communicating via the JS-Native bridge and maybe even make card validation async as well

DZuz14 commented 3 years ago

Cool. Sounds great! =)