I’m encountering an issue with Stripe integration in my Expo app when running it on a real iOS device.
Everything works fine on Android builds, iOS simulators, and Android simulators, but when I try to add a payment card on the real iOS build, I get the following error:
Error code: Failed You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g. 'Authorization: Bearer YOUR_SECRET_KEY'). See https://stripe.com/docs/api#authentication for details, or we can help at https://support.stripe.com/.
What I’ve Done:
I followed the Expo/Stripe documentation and have provided the publishable key in the frontend using the component, like this:
<StripeProvider
publishableKey={process.env.EXPO_PUBLIC_STRIPE_PKEY}
urlScheme="your-url-scheme" // required for 3D Secure and bank redirects
merchantIdentifier="merchant.com.{{YOUR_APP_NAME}}" // required for Apple Pay
>
- The API keys are correctly set in the environment variables.
- On Android, iOS simulators, and Android build, everything works as expected.
- The issue happens only on real iOS devices.
Setup:
- Expo SDK version: 50
- API version: 2024-04-10
- @stripe/stripe-react-native: ~0.35.1
- react-native: 0.73.6
- Device: iPhone13 (iOS 18.1.1)
What I’ve Tried:
- Verified that the API key is correct and correctly loaded in process.env.EXPO_PUBLIC_STRIPE_PKEY.
- Double-checked the relevant documentation for iOS integration with Expo/Stripe, but nothing seems to address this specific error.
Miko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.