Stripe
Our templates use Stripe to handle payments and subscriptions.
Follow these steps to set it up in your project.
1. Get Your Stripe Secret Key
- Log in to your Stripe Dashboard .
- Go to Developers → API keys.
- Copy the Secret key and add it to your
.env
file:
STRIPE_SECRET_KEY=your-secret-key
💡 Tip: Use the test mode key while developing. Switch to live keys when you deploy to production.
2. Create Products
- In the Stripe Dashboard, go to Product catalog.
- Click + Create product and add your product details.
- Click on the product you created and open its Price.
- Copy the Price IDs for each plan and save them in your
.env
file:
STRIPE_STARTER_PRICE_ID=
STRIPE_GROWTH_PRICE_ID=
STRIPE_ENTERPRISE_PRICE_ID=
You can update the pricing card data in the /data/index.ts
file.
3. Set Up Webhooks
Webhooks allow Stripe to notify your app when events occur (like subscription created, payment succeeded, or subscription canceled).
- In the Dashboard, go to Developers → Webhooks.
- Click + Add endpoint and set the endpoint URL to your app’s webhook route.
https://yourdomain.com/api/auth/stripe/webhook
We are using @better-auth/stripe plugin to integrate auth and payment, that’s why the webhook url contains /auth
- Select relevant events (e.g.
checkout.session.completed
,customer.subscription.updated
,invoice.payment_succeeded
). - Copy the Signing secret and add it to your
.env
file:
STRIPE_WEBHOOK_SECRET=whsec_123
4. Local Testing with stripe listen
To test webhooks locally, you can use Stripe’s CLI tool.
- Install Stripe CLI .
- Run the following command in your terminal:
stripe listen --forward-to localhost:3000/api/webhooks/stripe
This will forward all Stripe events to your local endpoint and provide a Webhook Signing Secret you can use for development:
STRIPE_WEBHOOK_SECRET=whsec_test_123
Once this setup is complete, your template will be ready to handle subscriptions end-to-end.
✅ Next step: Test your checkout flow in Stripe’s test mode before going live.