
A complete, production-minded guide to Stripe in React Native with Expo: the server endpoint, the PaymentSheet, Apple Pay and Google Pay, webhooks that confirm payment, test cards, and when the App Store requires in-app purchase instead.
TL;DR: to take card payments in an Expo app, install @stripe/stripe-react-native, create a PaymentIntent on your server (here, a Supabase Edge Function) that calculates the amount, return its client secret to the app, then open Stripe's prebuilt PaymentSheet with initPaymentSheet and presentPaymentSheet. Turn on Apple Pay and Google Pay in the same call. Fulfill orders only when your server receives the payment_intent.succeeded webhook. And remember: Stripe is for physical goods and real-world services; digital content used inside the app generally needs Apple's and Google's in-app purchase.
Can you use Stripe in a React Native app on the App Store?
Yes, for the right kind of purchase. App Store and Google Play rules split purchases into two groups:
- Physical goods and real-world services: food orders, retail products, tickets, rides, appointments, classes, consulting. You can use Stripe or any payment processor.
- Digital goods and services used in the app: premium features, subscriptions to app content, in-app currency, digital courses. These generally must use Apple's and Google's in-app purchase systems.
Payment rules have changed in some regions in recent years, so check the current App Store Review Guidelines (section 3.1) and Google Play's Payments policy for where you sell. This guide covers the first group: real-world payments with Stripe.
How does a Stripe payment flow work in a mobile app?
The app never decides how much to charge, and it never sees your secret key. The flow is:
- The app sends the cart to your server (item IDs and quantities, not prices).
- Your server calculates the amount from your database and creates a PaymentIntent with Stripe's secret key.
- The server returns the PaymentIntent's client secret (plus customer details if you save cards).
- The app opens the PaymentSheet, where the user pays with a card, Apple Pay or Google Pay. Stripe handles 3D Secure and other authentication.
- Stripe sends a webhook (
payment_intent.succeeded) to your server. - Your server marks the order as paid and starts fulfillment.
The client can show "Payment complete" right away, but the webhook is the source of truth.
Step 1: Install the Stripe SDK in Expo
npx expo install @stripe/stripe-react-native
Add the config plugin to app.json. The merchant identifier is needed for Apple Pay, and Google Pay is switched on here:
{
"expo": {
"scheme": "myapp",
"plugins": [
[
"@stripe/stripe-react-native",
{
"merchantIdentifier": "merchant.com.yourcompany.yourapp",
"enableGooglePay": true
}
]
]
}
}
Basic card payments can be tried in Expo Go, but Apple Pay, Google Pay and your real app configuration require a development build, so build one once the plugin is added.
Step 2: Wrap the app in StripeProvider
// app/_layout.tsx
import { StripeProvider } from '@stripe/stripe-react-native';
import { Stack } from 'expo-router';
export default function RootLayout() {
return (
<StripeProvider
publishableKey={process.env.EXPO_PUBLIC_STRIPE_PUBLISHABLE_KEY!}
merchantIdentifier="merchant.com.yourcompany.yourapp"
urlScheme="myapp"
>
<Stack />
</StripeProvider>
);
}
- The publishable key (
pk_test_...orpk_live_...) is safe in the app. - The secret key (
sk_...) must never be in the app or in anEXPO_PUBLIC_variable. - The URL scheme lets Stripe return to your app after redirect-based authentication, such as some bank verification flows.
Step 3: Create the PaymentIntent on your server
Here's a Supabase Edge Function. It verifies the user, prices the cart from the database, creates or reuses a Stripe customer and returns what the PaymentSheet needs:
// supabase/functions/create-payment/index.ts
import Stripe from 'npm:stripe';
import { createClient } from 'npm:@supabase/supabase-js@2';
const stripe = new Stripe(Deno.env.get('STRIPE_SECRET_KEY')!, {
httpClient: Stripe.createFetchHttpClient(), // fetch-based client for Deno
});
Deno.serve(async (req) => {
const supabase = createClient(
Deno.env.get('SUPABASE_URL')!,
Deno.env.get('SUPABASE_ANON_KEY')!,
{ global: { headers: { Authorization: req.headers.get('Authorization') ?? '' } } }
);
const { data: { user } } = await supabase.auth.getUser();
if (!user) return new Response('Unauthorized', { status: 401 });
const { items } = await req.json(); // [{ id, quantity }]
// Price the cart on the server. Never trust prices sent by the app.
const { data: products } = await supabase
.from('products')
.select('id, price_cents')
.in('id', items.map((i: { id: string }) => i.id));
const amount = items.reduce((sum: number, i: { id: string; quantity: number }) => {
const product = products?.find((p) => p.id === i.id);
return sum + (product ? product.price_cents * i.quantity : 0);
}, 0);
if (amount <= 0) return new Response('Empty cart', { status: 400 });
// Reuse one Stripe customer per user (store the ID on your profiles table)
const customer = await stripe.customers.create({ metadata: { user_id: user.id } });
const ephemeralKey = await stripe.ephemeralKeys.create(
{ customer: customer.id },
{ apiVersion: 'YOUR_STRIPE_API_VERSION' } // match the version your SDK expects
);
const paymentIntent = await stripe.paymentIntents.create({
amount,
currency: 'usd',
customer: customer.id,
automatic_payment_methods: { enabled: true },
metadata: { user_id: user.id },
});
return Response.json({
paymentIntent: paymentIntent.client_secret,
ephemeralKey: ephemeralKey.secret,
customer: customer.id,
});
});
Two notes:
- The amount is calculated from your database. If the app sent a total, anyone could change it.
- Customers and ephemeral keys are only needed if you want saved cards. For guest checkout, you can create just the PaymentIntent and skip both. In production, store the Stripe customer ID on the user's profile and reuse it instead of creating a new one per payment.
Step 4: Open the PaymentSheet in the app
// src/payments/useCheckout.ts
import { useState } from 'react';
import { Alert } from 'react-native';
import { useStripe } from '@stripe/stripe-react-native';
import { supabase } from '@/lib/supabase';
export function useCheckout() {
const { initPaymentSheet, presentPaymentSheet } = useStripe();
const [loading, setLoading] = useState(false);
async function checkout(items: { id: string; quantity: number }[]) {
setLoading(true);
try {
const { data, error } = await supabase.functions.invoke('create-payment', {
body: { items },
});
if (error) throw error;
const init = await initPaymentSheet({
merchantDisplayName: 'Corner Cafe',
paymentIntentClientSecret: data.paymentIntent,
customerId: data.customer,
customerEphemeralKeySecret: data.ephemeralKey,
returnURL: 'myapp://stripe-redirect',
applePay: { merchantCountryCode: 'US' },
googlePay: { merchantCountryCode: 'US', testEnv: __DEV__ },
allowsDelayedPaymentMethods: false,
});
if (init.error) throw init.error;
const result = await presentPaymentSheet();
if (result.error) {
if (result.error.code !== 'Canceled') Alert.alert('Payment failed', result.error.message);
return false;
}
return true; // show "Order placed"; the webhook confirms it on the server
} finally {
setLoading(false);
}
}
return { checkout, loading };
}
The PaymentSheet handles card entry, validation, saved cards, Apple Pay, Google Pay and authentication like 3D Secure. You get a polished, accessible checkout without building any of it.
Step 5: Confirm payments with a webhook
The app saying "success" isn't proof of payment: the user could close the app, lose connection or tamper with it. Confirm on the server:
// supabase/functions/stripe-webhook/index.ts
import Stripe from 'npm:stripe';
import { createClient } from 'npm:@supabase/supabase-js@2';
const stripe = new Stripe(Deno.env.get('STRIPE_SECRET_KEY')!, {
httpClient: Stripe.createFetchHttpClient(),
});
const cryptoProvider = Stripe.createSubtleCryptoProvider();
Deno.serve(async (req) => {
const signature = req.headers.get('Stripe-Signature');
const body = await req.text(); // raw body is required for verification
let event: Stripe.Event;
try {
event = await stripe.webhooks.constructEventAsync(
body, signature!, Deno.env.get('STRIPE_WEBHOOK_SECRET')!, undefined, cryptoProvider
);
} catch {
return new Response('Invalid signature', { status: 400 });
}
if (event.type === 'payment_intent.succeeded') {
const intent = event.data.object as Stripe.PaymentIntent;
const admin = createClient(Deno.env.get('SUPABASE_URL')!, Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!);
await admin.from('orders').update({ status: 'paid' }).eq('payment_intent_id', intent.id);
}
return new Response('ok');
});
Key points:
- Use the raw body and Stripe's signature check, with the async version and the subtle crypto provider in edge runtimes.
- Make handling idempotent. Stripe can deliver the same event more than once; updating an order to "paid" twice should be harmless.
- Deploy this function without requiring a user JWT, since Stripe calls it directly; the signature check is what protects it.
- Store the PaymentIntent ID on the order when you create it, so the webhook can find it.
How do you set up Apple Pay and Google Pay?
Apple Pay:
- Create a merchant ID in your Apple Developer account (for example
merchant.com.yourcompany.yourapp). - Create an Apple Pay certificate for it in the Stripe Dashboard's Apple Pay settings, following Stripe's steps.
- Use the same merchant ID in the config plugin and
StripeProvider, then make a new build.
Google Pay:
- Set
enableGooglePay: truein the config plugin. - Pass
googlePayoptions toinitPaymentSheet, usingtestEnv: truewhile testing. - Before going live, follow Google Pay's production requirements for your app.
When both are configured, the PaymentSheet shows them automatically on supported devices.
How do you test Stripe payments in Expo?
Use your test mode keys and Stripe's test cards:
4242 4242 4242 4242: a successful payment (any future date, any CVC).- A 3D Secure test card from Stripe's testing docs, to check authentication and your return URL.
- Decline test cards, to check your error messages.
For webhooks during development, the Stripe CLI can forward events to your function, and you can trigger test events from the Stripe Dashboard. Test the full loop: pay, receive the webhook, see the order marked as paid.
What are the most common Stripe + Expo mistakes?
- Calculating the price in the app. Always price on the server.
- Putting the secret key in the app or in an
EXPO_PUBLIC_variable. - Fulfilling orders on the client's "success" instead of the webhook.
- Forgetting a new build after adding the config plugin or changing the merchant ID.
- No return URL or scheme, so redirect-based authentication can't come back to the app.
- Using Stripe for digital content that the stores require to go through in-app purchase.
- Creating a new Stripe customer for every payment, which breaks saved cards. Store and reuse one per user.
Pre-launch checklist
- Live publishable key in the app; live secret key and webhook secret only on the server.
- Prices calculated on the server.
- Webhook endpoint registered in live mode, with signature verification.
- Orders fulfilled only after
payment_intent.succeeded. - Apple Pay certificate and merchant ID configured; Google Pay production requirements met.
- Tested with success, decline and 3D Secure cards on real devices.
- Purchases are physical goods or real-world services, not digital content requiring in-app purchase.
Frequently asked questions
Does Stripe work in Expo Go?
Basic card payments can be tried in Expo Go, but Apple Pay, Google Pay and your production configuration need a development build with the Stripe config plugin.
Should I use PaymentSheet or build my own card form?
PaymentSheet for almost every app. It handles card validation, wallets, saved cards, authentication and accessibility, and Stripe keeps it up to date.
Can I use Stripe for subscriptions in my app?
For subscriptions to real-world services (a gym membership, a meal plan delivered to the door), yes. For subscriptions to digital content or features inside the app, the stores generally require in-app purchase.
Where should the server code run?
Anywhere you can keep secrets: Supabase Edge Functions, your own Node.js API or serverless functions. The pattern is the same.
Conclusion
Stripe payments in Expo come down to a clear split: the server prices the cart, creates the PaymentIntent and confirms payment through webhooks; the app opens the PaymentSheet with Apple Pay and Google Pay built in. Keep secrets on the server, fulfill on the webhook and use Stripe only for real-world purchases.
If you're starting a new app, RapidNative generates Expo projects with Supabase that you can export and add this payment flow to.
Which part of Stripe in Expo gave you the most trouble: Apple Pay setup, webhooks or 3D Secure? Share it in the comments.
About the author
- Full Stack Developer. Building end-to-end products that just work.
Comments
Join the discussionNo comments yet. Be the first to comment.
