capacitor-community / stripe

Stripe Mobile SDK wrapper for Capacitor
MIT License
185 stars 75 forks source link

isApplePayAvailable always undefined, createApplePay works fine #307

Closed alexcroox closed 8 months ago

alexcroox commented 9 months ago

Platform

Describe the bug I believe I've followed all the setup steps but I'm still getting undefined back from my initial isApplePayAvailable() call.

What exactly does that function check for? Does it check the user is on iOS and they have a card setup in their wallet?

image

image

server: {
  androidScheme: 'https',
  iosScheme: 'ionic'
}
import { Stripe as NativeStripe } from '@capacitor-community/stripe'

const isApplePayAvailable = await NativeStripe.isApplePayAvailable()

console.log({ isApplePayAvailable })

^ always undefined. I'm using NativeStripe because I already have Stripe JS SDK for payments using Stripe elements (that works fine in production on Capacitor iOS and Android)

I've also tried initialising first

 NativeStripe.initialize({
  publishableKey: process.env.STRIPE_PUBLISHABLE_KEY
})

I've tried this on both the iOS simulator, and deployed a proper build through TestFlight on a device that has Apple Pay setup and it still fails. I've also tried a sandbox account on the simulator with Apple pay enabled on the sandbox account.

I've run out of ideas!

alexcroox commented 9 months ago

If I ignore the result of isApplePayAvailable and just call createApplePay() everything goes through fine, I just want to know why that initial check fails.

rdlabo commented 8 months ago

Yes. This method return void.

Please check how to use: https://github.com/capacitor-community/stripe/blob/main/demo/angular/src/app/demo/demo.page.ts#L151

alexcroox commented 8 months ago

Ah ok. Usually functions that start with “is” return booleans. Something to consider to avoid future confusion for others. Thanks.