Tipsi-stripe: AndroidPay test environment

Created on 31 Aug 2018  路  9Comments  路  Source: tipsi/tipsi-stripe

Trying to work with NativePay using tipsi-stripe.
ApplePay works perfectly, both dev and prod mode.
AndriodPay didn't work in test mode, in prod and TEST mode it said that we need to be accepted by google (its ok), but to be accepted we need to provide APK with working test mode.
On Android even deviceSupportsNativePay and canMakeNativePayPayments method crush application with critical error.

Environment

  • tipsi-stripe version: "5.6.0"
  • iOS or Android: Android issue
  • OS version: sdk 25,26,27 tried on MI, Redmi5, Samsung, Note, Pixel
  • React-Native version: "0.56.0"
  • (Android only) com.google.firebase:firebase-core version: 16.0.1
  • (Android only) com.google.android.gms:play-services-base version: 15.0.1

  • android.compileSdkVersion 26

  • android.buildToolsVersion 26.0.3
  • android.defaultConfig.minSdkVersion 23
  • android.defaultConfig.targetSdkVersion 26
  • android.defaultConfig.multiDexEnabled (if exists)

2018-08-31 16 58 07
2018-08-31 16 58 18
img_0974
android

Most helpful comment

@CelsiusWilliams You need to call setOptions before using any other methods. The Android code has a default value for the Environment that is invalid and throws an Exception not handled by the library. The setOptions method sets the Environment.

E.g.:

```

stripe.setOptions({
publishableKey: 'pk_test_fromstripe',
merchantId: 'applemerchantid', // Optional
androidPayMode: 'test', // Android only
})
const paymentSupported = await stripe.deviceSupportsNativePay();
```

All 9 comments

Additional information:
paymentRequestWithCardForm method works great for IOS and Android.
If I do not use deviceSupportsNativePay and canMakeNativePayPayments methods, but run paymentRequestWithNativePay in TEST mode with TEST token, then I get message that I need to be accepted by google.

android2 2

@perfectdim Hi! Try to run deviceSupportsNativePay or canMakeNativePayPayments before try to pay. These methods exists not just for fun.
Wrap all these requests with try-catch call and see an error.

async function pay() {
  try {
    // Indicates about google pay availability
    const isDeviceSupportsNativePay = await stripe.deviceSupportsNativePay()
    const isUserHasAtLeastOneCardInGooglePay = await stripe.canMakeNativePayPayments()

    if (isDeviceSupportsNativePay && isUserHasAtLeastOneCardInGooglePay) {
      await stripe. paymentRequestWithNativePay(options)
    }
  } catch (error) {
    console.log(error) // In debug mode see the error
    showUserAMessageAboutHisDeviceOrAboutHisCardsOrSomethingElse()
  }
}

@isnifer Thank you, for fast reply.
But as I said before, these methods crash the app.
even using try-catch wrapping :/

try {
    nativePay = await stripe.deviceSupportsNativePay();
} catch (error) {
    alert(JSON.stringify(error));
} 
try {
    canPay = await stripe.canMakeNativePayPayments();
} catch (error) {
    alert(JSON.stringify(error));
} 

solved.
This should be in application tag =)

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

my fault ))

I am having the same problem. But I have this meta-data tag in my manifest already

@CelsiusWilliams You need to call setOptions before using any other methods. The Android code has a default value for the Environment that is invalid and throws an Exception not handled by the library. The setOptions method sets the Environment.

E.g.:

```

stripe.setOptions({
publishableKey: 'pk_test_fromstripe',
merchantId: 'applemerchantid', // Optional
androidPayMode: 'test', // Android only
})
const paymentSupported = await stripe.deviceSupportsNativePay();
```

@cjvilla2012
Thanks, I already got it working.

So when we use a live stripe key, we need to change the androidPayMode to production?

@prameetc Yes

Was this page helpful?
0 / 5 - 0 ratings