packages/platform/atoms/STRIPE.md
This guide will help you set up Stripe locally to test platform billing subscriptions for different platform plans.
.env fileSign up for a Stripe account at stripe.com. You don't need to complete the full account activation process (payment details, company information, etc.) for testing purposes.
Access your Stripe Dashboard at dashboard.stripe.com
Switch to Test mode by clicking the toggle in the top left corner of the dashboard.
Navigate to Developers → API keys from the left sidebar.
Copy your Publishable key. This will be used as STRIPE_API_KEY in your API v2 .env file.
The Stripe CLI is required to listen for webhook events generated by Stripe. This is necessary because the checkout flow triggers events that need to be forwarded to your local API v2 webhook endpoint.
Install the Stripe CLI using Homebrew:
brew install stripe/stripe-cli/stripe
Authenticate the CLI with your Stripe account:
stripe login
Update the following environment variables in your API v2 .env file:
Add the Publishable key you copied in Step 1:
STRIPE_API_KEY=pk_test_your_publishable_key_here
Run the following command in your terminal to start listening for Stripe events and generate a webhook signing secret:
stripe listen --forward-to http://localhost:5555/api/v2/billing/webhook
Copy the webhook signing secret from the command output (it will look like whsec_...).
Add it to your .env file:
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret_here
Note: Keep this terminal session running while testing, as it forwards Stripe events to your local webhook endpoint.
You need to create products in Stripe and configure their price IDs in your .env file. The following environment variables are available:
STRIPE_PRICE_ID_STARTER=
STRIPE_PRICE_ID_STARTER_OVERAGE=
STRIPE_PRICE_ID_ESSENTIALS=
STRIPE_PRICE_ID_ESSENTIALS_OVERAGE=
STRIPE_PRICE_ID_ENTERPRISE=
STRIPE_PRICE_ID_ENTERPRISE_OVERAGE=
To set up products:
In your Stripe Dashboard, navigate to Products → Product catalogue from the left sidebar.
Create two products for each plan you want to test:
For each product:
price_)Add the Price IDs to your .env file. For example, if testing the Essentials plan:
STRIPE_PRICE_ID_ESSENTIALS="price_1SXkelSliJQGPobQxR5L8nb5"
STRIPE_PRICE_ID_ESSENTIALS_OVERAGE="price_1SXl1ZSliJQGPobQR55aQ0j9"
Note: You only need to configure the price IDs for the plans you want to test. You can use the same price IDs for multiple products if desired.
Important: This step is only required for local development.
In apps/api/v2/src/modules/billing/services/billing.service.ts, ensure that quantity: 1 is set on line 88. This is a known workaround for local development (this works correctly in production without modification).
Start the API v2 server:
yarn start
Note: It's recommended to use
yarn startinstead ofyarn devfor testing Stripe integrations.
Start the web application in a separate terminal.
Navigate to /settings/platform/new in your browser.
Create a new platform account.
Click on one of the plan cards to initiate the Stripe checkout flow.
Use the following test card details:
4242 4242 4242 4242Complete the checkout process.
Verify the integration:
PlatformBilling table in your database for a new entry containing:
Ensure the Stripe CLI terminal (from Step 3.2) is still running to receive webhook events.