Setting Up Stripe Live Mode
Transitioning from Stripe's test mode to live mode is a crucial step in preparing your application for production. This guide will walk you through the process of setting up Stripe live mode and creating your products and prices.
Prerequisites
- A Stripe account with completed verification for live mode.
- Your application's Stripe integration tested thoroughly in test mode.
Steps to Set Up Stripe Live Mode
1. Switch to Live Mode
- Log in to your Stripe Dashboard.
- In the top-right corner, switch from "Test Data" to "Live" mode.
2. Set Up Your Live Webhook
To streamline the webhook setup process, you can use the following pre-configured Stripe webhook creation link:
Create Stripe Webhook with Pre-configured Events
If you'd rather set up the webhook manually, follow these steps:
- In the Stripe Dashboard, go to "Developers" > "Webhooks".
- Click "Add endpoint".
- Enter your production webhook URL:
https://yourdomain.com/api/stripe/webhook
. - Select the following events to listen to:
checkout.session.completed
customer.subscription.created
customer.subscription.updated
customer.subscription.deleted
invoice.paid
invoice.payment_failed
customer.updated
customer.deleted
payment_intent.succeeded
payment_intent.payment_failed
charge.succeeded
- Click "Add events", then "Add endpoint" to create your webhook.
- Note down the "Signing secret" for your webhook.
3. Create Products and Prices
- Navigate to "Products" in your Stripe Dashboard.
- Click "Add product" for each product you want to offer.
- Fill in the product details, including name and description.
- Under "Pricing", set up your pricing tiers:
- For recurring subscriptions, choose "Recurring price".
- Set the price and billing interval (e.g., $10 per month).
- Click "Save product" to create the product and its associated price.
4. Update Your Application Configuration
Update your config/index.ts
file with the live mode values.
Obtaining Stripe API Keys
Before setting up your live webhook, you'll need to obtain your Stripe API keys for production use. These keys are essential for authenticating your requests to the Stripe API.
-
Go to the Stripe API Keys page.
-
You'll find two types of keys here:
- Publishable key (starts with
pk_live_
) - Secret key (starts with
sk_live_
)
- Publishable key (starts with
-
Copy your live Publishable key and update it in your
apps/web/.env.local
file:NEXT_PUBLIC_STRIPE_PUBLIC_KEY=pk_live_your_live_publishable_key
-
Copy your live Secret key and update it in your
apps/web/.env.local
file:STRIPE_SECRET_KEY=sk_live_your_live_secret_key
⚠️ Important: Never share your Secret key publicly or commit it to version control. Always use environment variables to store sensitive information.
- Make sure to update these keys in your production environment as well.