triniwiz / nativescript-plugins

Apache License 2.0
78 stars 50 forks source link

[Stripe][android] getPayment method undefined #165

Closed kefahB closed 1 year ago

kefahB commented 1 year ago

Hi @triniwiz

The flowing error Cannot read property 'getPaymentMethod' of undefined occur when we the payment method is found and the payment button become clickable and the user click on it as quick he can, then the isPaymentReadyToCharge for some reason does not get populated causing app crash.

I think putting also a null safe operator can prevent from future crash because it can be captured with the id check.

  System.err: Calling js method run failed
  System.err: TypeError: Cannot read property 'getPaymentMethod' of undefined
  System.err:
  System.err: StackTrace:
  System.err: (file: app/webpack:/cocarz/node_modules/@triniwiz/nativescript-stripe/standard/index.android.js:129:0)
  System.err:   at invoke(file: app/webpack:/cocarz/node_modules/@nativescript/core/timer/index.android.js:22:0)
  System.err:   at run(file: app/webpack:/cocarz/node_modules/@nativescript/core/timer/index.android.js:26:0)
  System.err:   at com.tns.Runtime.callJSMethodNative(Native Method)

https://github.com/triniwiz/nativescript-plugins/blob/b44bdd082e43b345e1cc5c1f0f4bbabc295c2d7f/packages/nativescript-stripe/standard/index.android.ts#L160

kefahB commented 1 year ago

166