triniwiz / nativescript-plugins

Apache License 2.0
80 stars 51 forks source link

[nativescript-stripe] confirmSetupIntent throws an error #110

Closed sebj54 closed 1 year ago

sebj54 commented 2 years ago

Hi there!

I just updated the nativescript-stripe plugin to the latest version. It turns out that my implementation does not work anymore.

So far, the payment method creation still works, but when I want to confirm setup intent with:

stripe.confirmSetupIntent(paymentMethod.id, this.clientSecret, onSuccessCallback)

I have this error:

TypeError: error.getMessage is not a function

It is thrown in this catch block: https://github.com/triniwiz/nativescript-plugins/blob/12f13aeb7361cb9c28554bcb90974587e5527084/packages/nativescript-stripe/index.android.ts#L660-L662

This happens because the error is not a Stripe error but a JS exception:

 Error: java.lang.NoSuchMethodError: no static method "Lcom/stripe/android/Stripe;.confirmSetupIntent(Landroidx/activity/ComponentActivity;Lcom/stripe/android/model/ConfirmSetupIntentParams;)V"

I wanted to debug this, but I'm a bit lost with Stripe Android documentation… There seems to be two confirmSetupIntent methods with a different signature:

Thanks in advance for your help 🙏

sebj54 commented 2 years ago

So I digged deeper to find a solution and can't find it.

There is a method with the same signature (inspected with java.util.Arrays.toString(this.stripe.getClass().getMethods())):

public final void com.stripe.android.Stripe.confirmSetupIntent(androidx.activity.ComponentActivity,com.stripe.android.model.ConfirmSetupIntentParams)

I don't understand why it looks for a static method on Stripe instance, maybe that's part of the problem?

Is this method working on your side?

triniwiz commented 2 years ago

What does console.log(androidx.activity.ComponentActivity) print ?

sebj54 commented 2 years ago

It prints function () { [native code] }

Stanteq commented 2 years ago

I have the same problem on Android 10

triniwiz commented 2 years ago

Can you try 9.0.0-alpha.0 version of stripe along with 8.4.0-alpha.0 of the android runtime

Stanteq commented 2 years ago

@triniwiz Unfortunately this (9.0.0-alpha.0) does not fix the problem (tested on Android 10 & 13).

matteonatale commented 1 year ago

Hi there, I'm having the same issue of @sebj54 and I'm in the same condition: after plugin update my implementation does not work either. Is there any news?

sebj54 commented 1 year ago

Hi @triniwiz, I just tested the latest version (9.0.0-beta.1) and it still has the same problem. How can I help? Do you need a reproduction?

sebj54 commented 1 year ago

The error seems fixed with latest beta (9.0.0-beta.2). Thanks @triniwiz!