How to Add Stripe Payments
One-off payments and subscriptions, with the webhook handling that keeps your database in sync.
Published 24 Aug 2026 · Tested with Lovable as of 24 Aug 2026

Overview
Payments have three parts: creating a checkout, receiving the result, and recording it reliably through webhooks.
Beginner explanation: The webhook is the part people skip. Without it, a customer can pay and your app never finds out.
Technical explanation: Create checkout sessions server-side, verify webhook signatures, and treat the webhook — not the browser redirect — as the source of truth for payment state.
Steps
- Add your secret key as a server secret.
- Create checkout sessions from server code only.
- Add a public webhook endpoint and verify the signature.
- Update the customer record from the webhook, not the redirect.
- Test with test cards including a declined card.
:::tip Always test the failure paths: declined card, abandoned checkout, and a duplicate webhook delivery. :::
What to check afterwards
- Successful payment updates the database
- A closed browser tab still results in a recorded payment
- Declined payments do not grant access
Common problems
- Trusting the success redirect. The customer can close the tab.
- Unverified webhooks. Anyone can fake a payment.
- No idempotency. Duplicate deliveries double-charge your data.
Where people get stuck
If you have followed the steps and the result still is not right, the fastest path is usually to describe the exact behaviour you expected, the behaviour you got, and any error text, then ask for a fix in one focused follow-up prompt. If that loop is not converging, hand it over.