Tipsi-stripe: Exception in native call from JS

Created on 19 Jun 2019  路  10Comments  路  Source: tipsi/tipsi-stripe

Before I have submitted the issue

[x] I have read an installation guide
[x] I know that for an iOS I need to install pods because I've read the installation guide
[x] I have read a linking guide and checked that everything is OK like in manual linking guide
[x] I know that before using tipsi-stripe I need to set options for my app as described in usage guide

The problem

Briefly describe the issue you are experiencing (or the feature you want to see added to tipsi-stripe).

Running Android app causes a crash with the below image.

Exception in native call from JS

I have went through the docs and everything seems to be linked properly.

There was not much else inside the [installation docs](https://tipsi.github.io/tipsi-stripe/docs/installation.html.

I looked around and added

implementation "com.google.android.gms:play-services-wallet:16.0.1"

to my dependencies in /android/app/build.gradle file.

Any idea how I could proceed from here?

I am not a native Android dev by any means so, perhaps something is out of date?

Environment

  • tipsi-stripe version: 7.5.0
  • Android:
  • OS version: MacOS 10.14.5
  • React-Native version: 0.59.9
  • (Android only) com.google.firebase:firebase-core version: 16.0.9
  • (Android only) com.google.android.gms:play-services-base version: 16.1.0

For Android, please provide the following sections from android/app/build.gradle:

  • android.compileSdkVersion: 28
  • android.buildToolsVersion: 28.0.3
  • android.defaultConfig.minSdkVersion: 16
  • android.defaultConfig.targetSdkVersion: 28
  • android.defaultConfig.multiDexEnabled true

Screenshot_1560982109

wont-fix

Most helpful comment

For me it was three things (pretty much a combo of some of the above):
1) Put the following metadata inside of the already existing <application> tag in android/app/src/main/AndroidManifest.xml:

      <meta-data
        android:name="com.google.android.gms.wallet.api.enabled"
        android:value="true" />

2) In /android/app/build.gradle put the following inside of dependencies:
implementation 'com.google.android.gms:play-services-wallet:18.0.0'
3) When calling setOptions, make sure you have androidPayMode set like this:

stripe.setOptions({
    publishableKey: "STRIPE_KEY",
    androidPayMode: "test"
    // merchantId: 'MERCHANT_ID', // Optional
});

All 10 comments

Upon further investigation I was able to narrow it down to canMakeNativePayPayments() and deviceSupportsNativePay() as being the root cause for the above error for Android.

I am simply just checking for the Platform.OS property now and not calling it when it is Android.

Hopefully there will be a better workaround later on.

This is a pretty generic error, but I also was getting a similar error. This was due to sending a blank publishableKey. Once I set that, all is good.

This error occurred [for me] when using canMakeNativePayPayments and deviceSupportsNativePay (or the Android only equivalent) on android devices without using stripe.setOptions to set androidPayMode.

See the docs here

This version worked for me.

implementation "com.google.android.gms:play-services-wallet:16.0.0"

in dependencies in /android/app/build.gradle file.

and make sure you have put
<application> <meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true" /> </application>
in AndroidManifest.xml

I'm also having this issue, I tried adding in implementation "com.google.android.gms:play-services-wallet:16.0.0" but no dice

For me it was three things (pretty much a combo of some of the above):
1) Put the following metadata inside of the already existing <application> tag in android/app/src/main/AndroidManifest.xml:

      <meta-data
        android:name="com.google.android.gms.wallet.api.enabled"
        android:value="true" />

2) In /android/app/build.gradle put the following inside of dependencies:
implementation 'com.google.android.gms:play-services-wallet:18.0.0'
3) When calling setOptions, make sure you have androidPayMode set like this:

stripe.setOptions({
    publishableKey: "STRIPE_KEY",
    androidPayMode: "test"
    // merchantId: 'MERCHANT_ID', // Optional
});

My issue was that I was calling deviceSupportsNativePay before calling setOptions. Make sure you call setOptions before calling anything else in the library.

I had migrated from expo-payments-stripe to tipsi-stripe...

Then my setOptions was in a componentWillMount... I put it in the constructor and it worked.

Oh my

Thanks @calinpastean

This version worked for me.

implementation "com.google.android.gms:play-services-wallet:16.0.0"

in dependencies in /android/app/build.gradle file.

and make sure you have put
<application> <meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true" /> </application>
in AndroidManifest.xml

app is crashing

For me this was happening because I was calling stripe.setOptions multiple times (once with androidPayMode: 'text', another with 'production'. I removed the duplicate call and now it's not crashing.

Was this page helpful?
0 / 5 - 0 ratings