Stripe Integration
This guide will show you how to set up your Stripe account for testing and local development.
You need to clone the boilerpro-backend repository to follow this guide.
Once you deploy your app, you can follow the same steps, just make sure you’re using your live Stripe API keys and product IDs and you are no longer in test mode within the Stripe Dashboard.
To get started, you’ll need to create a Stripe account. You can do that here (opens in a new tab).
Need help? Ask us on Discord! (You need to purchase the pro plan!↗)
Ask us on DiscordGet your test Stripe API Keys
Once you’ve created your account, you’ll need to get your test API keys. You can do that by navigating to https://dashboard.stripe.com/test/apikeys (opens in a new tab) or by going to the Stripe Dashboard and clicking on the Developers.
- Click on the
Reveal test
key token button and copy theSecret key
. - Paste the
Secret key
in your.env
file underSTRIPE_KEY
.
STRIPE_KEY=your_secret_access_key
Create Test Products
To create a test product, go to the test products url (https://dashboard.stripe.com/test/products (opens in a new tab)), or after navigating to your dashboard, click the test mode toggle.
- Click on the
Add a product
button and fill in the relevant information for your product. - Make sure you select
Software as a service (SaaS)
as the product type. - For Subscription products, make sure you select
Recurring
as the billing type. - For One-time payment products, make sure you select
One-time
as the billing type. - If you want to add different price tiers for the same product, click the
Add another price
button at the bottom.
- After you save the product, you’ll be directed to the product page.
- Copy the price IDs and paste them in the .env.server file
- We’ve set you up with two example subscription product environment variables, HOBBY_SUBSCRIPTION_PRICE_ID= and PRO_SUBSCRIPTION_PRICE_ID=.
- As well as a one-time payment product/credits-based environment variable, CREDITS_PRICE_ID=.
- Note that if you change the names of the price IDs, you’ll need to update your server code to match these names as well
HOBBY_SUBSCRIPTION_PRICE_ID=<price_id>
PRO_SUBSCRIPTION_PRICE_ID=<price_id>
CREDITS_PRICE_ID=<price_id>
Create a Stripe Webhook
To create a Stripe webhook, go to the webhooks url (https://dashboard.stripe.com/test/webhooks (opens in a new tab)) and click the Add endpoint
button.
- Insert the endpoint url (get it from the Deploy section)
- Select
Latest API Version (2024-04-10)
- Select
checkout.session.completed
from the events list. - Finally, click the
Add endpoint
button.
Once you add the endpoint you will be redirected to the endpoint lists in the Stripe Dashboard. Click on the endpoint and copy the Secret key
.
- Paste the
Secret key
in your.env
file underSTRIPE_WEBHOOK_SECRET
.
STRIPE_WEBHOOK_SECRET=<webhook_secret>