To add payments to a vibe coded app, connect Stripe through your platform's integration or a server function, test everything with sandbox keys, and confirm payments with a verified webhook before you give anyone what they paid for. The AI can write most of it. Your job is keeping the secret parts secret.
Know your Stripe keys
Stripe's API key docs list three key types you'll meet:
| Key | Starts with | Safe in front-end code? |
|---|---|---|
| Publishable | pk_ | Yes. Used by Stripe.js and mobile SDKs |
| Restricted | rk_ | No. Server only, with permissions you choose |
| Secret | sk_ | No. Server only, with unrestricted access |
Stripe says only publishable keys are safe to expose outside your back end. It recommends restricted keys over secret keys for new integrations, because you can limit what a stolen key could do. It also says not to put keys in version control or share them over chat, and that includes your AI chat.
Sandbox keys contain _test_ and live keys contain _live_. Build with sandbox keys only.
Option 1: Your platform's Stripe integration
Lovable
Lovable's Stripe docs say you describe what you're selling in the chat, then enter a restricted or secret key in a Connect Stripe form, not the chat. Lovable stores it as a backend secret called STRIPE_SECRET_KEY that never appears in your code or repository. It needs a backend (Lovable Cloud or your own Supabase), and login only if you sell subscriptions.
Two warnings from those docs. The preview has no separate test environment, so with a live key, purchases in the preview are real charges. And webhooks are off by default; if you need them for fulfillment, ask Lovable to build the webhook function and finish setup in the Stripe dashboard.
Lovable also offers built-in payments, where it manages the Stripe or Paddle account for you so there are no keys to handle. That needs a paid plan.
Bolt
Bolt's Stripe docs say the integration needs a Bolt database or Supabase plus user authentication. You add a test secret key under Integrations, pick your Stripe products, and Bolt creates Supabase edge functions for checkout, webhooks and subscriptions. Bolt says it registers webhook endpoints and verifies signatures automatically.
Option 2: Build it with Stripe Checkout
In a code editor like Cursor or Claude Code, the simplest route is Stripe Checkout, a payment page hosted by Stripe. Your server creates a Checkout Session with the secret key, and the customer pays on Stripe's page.
A prompt that sets the right boundaries:
Add a "Buy" button that starts a Stripe Checkout session for a one-time payment. Create the session in a server-side function using the Stripe key from an environment variable, never in browser code. Add a webhook endpoint that verifies the Stripe signature and marks the order paid on checkout.session.completed. Make the fulfillment safe to run more than once for the same session.
Why you need a webhook
It's tempting to mark an order paid on your "thank you" page. Stripe's fulfillment guide says you can't rely on that, because customers aren't guaranteed to reach the page. Someone can pay and lose their connection before it loads.
Instead, Stripe sends your server a checkout.session.completed event. Slower payment methods like bank debits send checkout.session.async_payment_succeeded later. Stripe also says your fulfillment function might be called more than once, even at the same time, for the same session, so it must only fulfill once.
Verify every webhook
Without verification, anyone could send your endpoint a fake "payment succeeded" event. Stripe's webhook docs say to verify the Stripe-Signature header using the endpoint's signing secret, which starts with whsec_, and Stripe's official libraries. A few details the AI often gets wrong:
- Use the raw request body. Stripe says any change to the body makes verification fail.
- Return a 2xx quickly. Do slow work after responding.
- Handle duplicates. Log event IDs you've processed and skip repeats.
Test before you take real money
- Pay with Stripe's test card
4242 4242 4242 4242, any future expiry date and any CVC, as listed in Stripe's fulfillment guide. - Confirm the order is marked paid by the webhook, not the success page.
- Try a declined payment and a cancelled checkout.
- For local testing, Stripe's CLI can forward events to your machine with
stripe listen.
Going live with payments in a vibe coded app
Switch to live keys in your server environment, update any price IDs (Lovable notes live price IDs differ from test ones), create a live webhook endpoint with its own signing secret, and make one real purchase on the published app. Stripe's go-live checklist is worth reading first. It suggests rotating keys before launch in case they were saved somewhere outside your codebase during development.
Common mistakes
- A secret key in front-end code, or in a
VITE_orNEXT_PUBLIC_variable, which build tools put in the browser. - Trusting a price sent from the browser instead of using your Stripe prices.
- Fulfilling on the redirect instead of the webhook.
If your app doesn't have accounts yet, read how to add login first, and check how to deploy before you switch to live keys. Real monthly cost is one of the criteria in our platform comparison.