What Myndlab generates for Stripe
When your prompt includes a billing requirement, Myndlab produces a complete, production-ready Stripe integration rather than a stub. The generated code includes:
1
Checkout session endpoint
A FastAPI route that creates a Stripe Checkout session and returns the hosted URL. The frontend redirects users there at purchase time.
2
Webhook handler
A verified webhook endpoint that listens for Stripe events (checkout.session.completed, customer.subscription.updated, invoice.payment_failed, etc.) and updates the database accordingly.
3
Subscription status in the database
A subscriptions table (or column on users) that stores plan, status, and Stripe customer ID — so your app can gate features without hitting the Stripe API on every request.
4
Billing portal redirect
An endpoint that creates a Stripe Billing Portal session so users can manage their subscription, update payment details, or cancel — without you building that UI.
5
Plans page on the frontend
A React page listing each plan with its price and feature highlights, plus a checkout button for each tier.
Writing the prompt
The more specific your prompt, the better the generated integration. Mention plan names, prices, billing intervals, and any feature gating rules:
text
Add Stripe billing with a $29/mo Pro plan and a $99/mo Business plan.
Users on the free tier see an upgrade banner on any page that requires a paid
feature. Pro users get unlimited projects and API access. Business users also
get SSO, audit logs, and a dedicated support email. Cancelled subscriptions
should immediately downgrade the user to the free tier.
You can also request annual pricing, trial periods, per-seat pricing, or usage-based billing — describe the model in plain English and Myndlab will translate it into the appropriate Stripe product and price configuration.
The generated files
The Stripe integration spans three main files:
text
backend/
└── api/
└── routes/
└── billing.py # Checkout, webhook, portal endpoints
frontend/
└── src/
└── pages/
└── Billing.tsx # Plans page + upgrade bannersThe webhook handler validates the Stripe signature using STRIPE_WEBHOOK_SECRET before processing any event. This prevents replay attacks and spoofed events. The secret is automatically added to your project's environment variable list.
Setting up Stripe env vars
After generation, add the following environment variables in Project Settings › Environment variables:
bash
STRIPE_SECRET_KEY=sk_test_... # Your Stripe secret key
STRIPE_WEBHOOK_SECRET=whsec_... # From the Stripe dashboard webhook endpoint
STRIPE_PRO_PRICE_ID=price_... # Stripe Price ID for the Pro plan
STRIPE_BIZ_PRICE_ID=price_... # Stripe Price ID for the Business plan
⚠Watch out.Never hardcode Stripe keys in your source code. Always use environment variables. Keys committed to source control should be treated as compromised and rotated immediately via the Stripe dashboard.
To find your Price IDs, go to the Stripe dashboard › Products, open each plan, and copy the Price ID from the pricing section. Each price has its own ID (e.g. price_1ABC...).
Testing with Stripe test mode
Use test-mode keys (sk_test_...) while developing. Stripe provides test card numbers that trigger specific scenarios:
text
4242 4242 4242 4242 — successful payment
4000 0000 0000 9995 — card declined (insufficient funds)
4000 0025 0000 3155 — requires 3D Secure authentication
Use any future expiry date and any 3-digit CVC. To test webhook delivery locally, install the Stripe CLI and run:
bash
stripe listen --forward-to localhost:8000/api/billing/webhook
The CLI prints a webhook signing secret (whsec_...) — use this as your STRIPE_WEBHOOK_SECRET for local testing.
Going live
1
Switch to live keys
In the Stripe dashboard, toggle from Test to Live mode and copy your live secret key. Update STRIPE_SECRET_KEY in your Myndlab environment variables.
2
Create live products and prices
Products and prices created in test mode do not carry over to live mode. Recreate them in the Stripe dashboard under live mode and update STRIPE_PRO_PRICE_ID and STRIPE_BIZ_PRICE_ID.
3
Register the production webhook URL
In the Stripe dashboard, go to Developers › Webhooks and add your production backend URL (e.g. https://your-app.myndlab.app/api/billing/webhook). Copy the signing secret and update STRIPE_WEBHOOK_SECRET.
4
Test a real payment
Make a small real purchase to confirm the end-to-end flow works before announcing your launch.