Guides
Setup Payment with Stripe
Configure Stripe payment integration for local development and production deployment with Supabase edge functions.
Setup Payment with Stripe
Local Setup
Stripe CLI
Installation of Stripe CLI is only necessary for local development environments. Manual event triggering or webhook forwarding to localhost is optional.
- Install Stripe CLI:
Using Homebrew:
brew install stripe/stripe-cli/stripe- Log in to Stripe CLI:
stripe loginFollow the authentication prompts to connect your Stripe account.
Start Supabase Edge Functions
- Serve Edge Functions:
npm run supabase:webhook-serve- Forward Stripe events to local webhook:
npm run stripe:listen- Trigger Stripe events: Local event triggering example:
stripe trigger <EVENT>Alternatively, trigger events directly from the Stripe dashboard.
Deployment
For production deployment, update environment variables following these steps:
-
Update Environment Variables:
- Navigate to the Supabase dashboard
- Select your project
- Click
Edge Functionsin the sidebar - Select
Manage secrets - Add or update edge function environment variables
- Required environment variables:
- BASE_SUPABASE_URL: Supabase URL
- SERVICE_ROLE_KEY: Supabase service role key
- STRIPE_WEBHOOK_SIGNING_SECRET: Stripe webhook signing secret
- STRIPE_SECRET_KEY: Stripe secret key
- STRIPE_PUBLISHABLE_KEY: Stripe publishable key
-
Deploy Edge Function:
npm run supabase:webhook-deployPayment Initialization
Two Supabase edge functions manage payment initialization:
-
payment-data-native: Handles native application payments by verifying or creating customers, generating ephemeral keys from Stripe, creating payment intents, and returning values to trigger the native Stripe SDK.
-
payment-data-web: Manages web application payments by verifying or creating customers, using the Stripe backend SDK with pricing and product details to generate payment URLs, then redirecting clients to complete transactions.
Products, Plans and Pricing Management
All the products, prices and their plans are managed on the Stripe dashboard. Consult Stripe's official documentation for additional guidance on product and pricing configuration.