Stripe
Connect Stripe, create your plans, and complete your first test payment
Use Stripe to sell subscriptions or a one-time plan in your app. Start in test mode and follow the steps below to receive your first order.
This guide covers purchases from Account → Upgrade. To set the source-code purchase link on the public pricing page, use Source Code Checkout in admin settings.
Before you start
Complete login and admin setup and migrate D1. Prepare a Stripe account. Local development runs at http://localhost:3377.
1. Add your secret key
Switch Stripe Dashboard to test mode, open the developer API Keys page, and copy the Secret Key to .dev.vars:
STRIPE_SECRET_KEY=sk_test_your-test-secretThe checkout opens on Stripe, so you only need the Secret Key for this flow. Secret values go in .dev.vars locally and Worker secrets online; the admin area only shows whether they are configured.
2. Create products and prices
Create products and prices in the Stripe product catalog. Add monthly, yearly, or one-time prices for the plans you offer, then put their Price IDs in .env:
VITE_STRIPE_PRO_MONTHLY_PRICE_ID=price_your-monthly-price
VITE_STRIPE_PRO_YEARLY_PRICE_ID=price_your-yearly-price
VITE_STRIPE_LIFETIME_PRICE_ID=price_your-one-time-price
VITE_CURRENCY=USD
VITE_APP_URL=http://localhost:3377Match the plans in src/config/payment-config.ts to the products you created. You can give your AI coding tool this task:
Update the existing plans in
src/config/payment-config.tsto match my Stripe products. Use my Price IDs, amounts, and billing intervals, and remove plans I do not offer. Keep USD for the first test. Amounts are in cents: 990 means $9.90.
To include credits with a subscription, tell your AI coding tool how many to grant and how long they should last. Follow the credit guide to enable credits and check they arrive after payment.
3. Configure webhooks
Create a Webhook destination in Stripe Dashboard for production:
https://your-domain.com/api/payment/webhook/stripeSelect the events this project handles:
checkout.session.completedinvoice.payment_succeededinvoice.payment_failedcustomer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deleted
Copy that destination's Signing Secret to .dev.vars:
STRIPE_WEBHOOK_SECRET=whsec_your-signing-secretFor local testing, install and sign in to the CLI using the Stripe CLI guide, then forward events:
stripe listen --forward-to localhost:3377/api/payment/webhook/stripePut the terminal's whsec_... value in local .dev.vars, then restart pnpm dev. Use the CLI secret locally and the production destination secret online; they are separate secrets.
4. Verify payment
- Open Admin → Settings (
/admin/config), selectstripeas the payment provider, and save. If the setting is locked by an environment variable, change that value and restart. - Sign in with a test account that has no subscription. Open the avatar menu, choose Account → Upgrade, then select one of your configured plans.
- Complete payment with a Stripe test payment method.
- Confirm HTTP 200 in Stripe's webhook delivery records. Open
/admin/ordersand check the order status, amount, and account. - Return to the homepage and open Account to check the plan. If the plan grants credits, also check the balance and Usage records.
Before accepting real payments
The default payment return pages still need to be completed before launch. Changing an existing subscription is also unfinished; use a new account to test the first purchase.
Give your AI coding tool this task:
In
src/shared/components/landing/pricing/pricing-cards.tsxandsrc/routes/api/payment/checkout.ts, point successful and canceled checkouts to existing app pages. Verify both return paths and the paid order. Keep the unfinished/api/payment/upgradeflow out of the first-purchase test.
A completed test includes the paid order and any credit grant, as well as the checkout itself.
Go live
Use live-mode Secret Keys, product Price IDs, and Webhook Secrets. Set vars.VITE_APP_URL in wrangler.jsonc to your real domain (also used by production builds), then follow deployment to upload secrets and rebuild.
Next: configure credit packages, or consider Creem.