π³ Stripe Setup¶
¶
βοΈ Setup¶
1οΈβ£ Create a new Stripe account and enable payments
- (I know, boring... see you soon!)
2οΈβ£ Set your site information
- Go to [Settings] β [Public Details] and add your website URL.
3οΈβ£ Brand customization
- Go to [Settings] β [Branding] and add your logo and colors.
4οΈβ£ Enable customer email notifications
- Under [Settings] β [Customer Emails], enable successful payment and refund email notifications.
5οΈβ£ Enable the Customer Portal
- Under [Settings] β [Customer Portal], activate the portal link (for later use).
6οΈβ£ Fraud prevention
- In the search bar, type "rules" and click [Fraud Prevention > Rules]
- β
Make sure the first 3DS rule is enabled
- π‘ Itβs also recommended to enable the second rule
- π« Ensure payments are blocked if CVC check fails
7οΈβ£ Enable Test Mode
8οΈβ£ Create a new product
- Add a product and copy its Price ID (e.g. price_1ju5GD464564
)
- Add it to config.stripe.plans[0].priceId
in your config.js
file
9οΈβ£ Setup API keys
- Go to [Developers], copy your public and secret keys
- Add them to .env.local
under STRIPE_PUBLIC_KEY
and STRIPE_SECRET_KEY
π Local Webhook¶
π Setup Webhook locally
- Go to [Developers] β [Webhook] β [Test in local environment]
- After signing in to Stripe CLI, run this command to forward webhook events:
```bash stripe listen --forward-to localhost:3000/api/webhook/stripe ````
- Copy the Webhook Signing Secret and add it to
STRIPE_WEBHOOK_SECRET
in.env.local
π Going Live¶
β
Copy the webhook signing secret and add it to your .env.local
as STRIPE_WEBHOOK_SECRET
βοΈ Production Setup Steps:¶
1οΈβ£ Turn off Test Mode in the Stripe dashboard
2οΈβ£ Under [Developers], copy your keys:
STRIPE_SECRET_KEY
STRIPE_PUBLIC_KEY
π₯ Add them to your production environment variables
3οΈβ£ Under [Developers] β [Webhook], click [Add Endpoint]:
- Set endpoint to:
https://yourdomain.com/api/webhook/stripe
- β
Select event:
checkout.session.completed
(add more if needed) - π Copy the signing secret and add it to
STRIPE_WEBHOOK_SECRET
in your production environment
π Optional Configuration¶
4οΈβ£ Under [Balance] β [Manage Payouts], set a fixed payout date (e.g., 10th of every month)
5οΈβ£ Under [Settings] β [Customer Emails], enable payment success and refund emails
π³ Creating a Checkout¶
From the frontend, use the <ButtonCheckout />
component to automatically generate a one-time or subscription checkout session.
π Webhook & Subscription Handling¶
Your API listens to Stripe webhook events and updates the userβs access accordingly.
β
It toggles the value of hasAccess
(or has_access
in Supabase) to true
or false
based on whether the user should have access to paid resources.
π‘ You can add your custom logic to the endpoint:
/api/webhook/stripe
Examples:
- Grant user credits
- Send an email with a paid ebook
- Any other logic (e.g. product unlock, discount code delivery, etc.)