Guides · VibeVigil
How to Stop Fake "Paid" Users: Verify Stripe Webhooks in a Lovable, Bolt or Cursor App
If your app unlocks Pro when the browser says "payment worked," anyone can fake it. Learn three quick tests, how to verify Stripe webhook signatures in a Supabase Edge Function or server route, how to lock the plan column with RLS, and a ready-to-paste prompt for your coding agent.
Not sure your app is safe? Run a free scan first.
VibeVigil checks your live app for exposed keys, Supabase tables a stranger can read, missing security headers, SSL problems and downtime. Every issue comes with a ready-to-paste prompt for your coding agent.
Scan my app for free → (only scan apps you own)
How to Stop Fake "Paid" Users: Verify Stripe Webhooks in a Lovable, Bolt or Cursor App
You added Stripe. A test payment worked. The user became "Pro." Done?
Maybe not. Many AI-built apps decide who paid in the browser. For example, the success page runs code like "set plan to pro." If that is your app, a user can skip the payment and run that same code. Or they can send a fake "payment succeeded" message to your webhook.
This guide shows you how to check your app in 10 minutes and how to fix it. Only test apps you own.
The short answer
- Never trust the browser to say "I paid." The success page is only a "thank you" screen.
- Let Stripe tell your server. Stripe sends a webhook event (like
checkout.session.completed) to a URL on your server. - Check the signature on every webhook. Stripe signs each event in the
Stripe-Signatureheader. Your code must check it with your signing secret (it starts withwhsec_) before it trusts the event. - Only the server may change the plan. Users must not be able to edit their own
plan,is_proorcreditscolumn. - Handle repeats. Stripe can send the same event more than once. Save the event ID and skip ones you already handled.
Why this matters
Stripe's own docs say it clearly: without verification, an attacker could send fake webhook events to "trigger actions like fulfilling orders, granting account access, or modifying records" (Stripe: Manage webhook endpoints).
AI coding tools often build the happy path first:
- The checkout works.
- The success page flips the user to Pro.
- The webhook (if there is one) reads the JSON and trusts it.
That works in a demo. In real life, it means free Pro for anyone who looks.
Test 1: What makes a user "paid"? (2 minutes)
Ask your coding agent this (it only reads, it changes nothing):
Without changing any code, show me every place where a user's plan,
subscription, is_pro, credits or similar field is set or updated.
For each one, tell me: does it run in the browser or on the server?Red flag: any plan change that runs in browser code, such as a success page, a React component, or a supabase.from('profiles').update({ plan: 'pro' }) call in the frontend.
Test 2: Can a user upgrade themselves? (3 minutes)
Do this on your own app, with your own test account.
- Log in as a normal free user.
- Open the browser console (F12 → Console).
- If your app uses Supabase, your agent can show you how to run an update on your own profile row, setting
plantopro.
Good result: the update fails or changes nothing. Bad result: your account is now Pro. That means your RLS policy lets users edit their own plan column.
Not sure how to run this? Ask your agent: "Write a one-time test I can paste in the browser console to try changing my own plan column. It must only touch my own row."
Test 3: Does your webhook accept fake events? (2 minutes)
Find your webhook URL. It is often something like https://YOUR-PROJECT.supabase.co/functions/v1/stripe-webhook or https://yourapp.com/api/stripe/webhook.
Send it a fake event with no signature:
curl -i -X POST "https://YOUR-WEBHOOK-URL" \
-H "Content-Type: application/json" \
-d '{"type":"checkout.session.completed","data":{"object":{}}}'Good result: a 400 error, such as "No signatures found" or "signature verification failed." Bad result: a 200 OK. Your webhook trusts anyone.
The fix
Step 1: Verify the signature
Your webhook must read the raw request body, not the parsed JSON. Stripe's docs warn that some frameworks change the body before your code sees it, and then the check fails (Stripe: Manage webhook endpoints).
Here is the core of Supabase's official example for an Edge Function (Supabase: Handling Stripe Webhooks):
import Stripe from 'npm:stripe'
const stripe = new Stripe(Deno.env.get('STRIPE_API_KEY') as string)
const cryptoProvider = Stripe.createSubtleCryptoProvider()
Deno.serve(async (req) => {
const signature = req.headers.get('Stripe-Signature')
const body = await req.text() // raw body, not req.json()
let event
try {
event = await stripe.webhooks.constructEventAsync(
body,
signature!,
Deno.env.get('STRIPE_WEBHOOK_SIGNING_SECRET')!,
undefined,
cryptoProvider
)
} catch (err) {
return new Response('Bad signature', { status: 400 })
}
// Only now is it safe to act on event.type
return Response.json({ received: true })
})Two Supabase notes:
- Stripe can't send a Supabase login token, so this one function is deployed with JWT checks off (
supabase functions deploy --no-verify-jwt stripe-webhooks, per the same example). That is fine because the Stripe signature is the lock. Never turn off JWT checks on other functions just to "make it work." - Keep
STRIPE_API_KEYandSTRIPE_WEBHOOK_SIGNING_SECRETin Edge Function secrets. Never inVITE_orNEXT_PUBLIC_variables.
On Next.js or Node, use stripe.webhooks.constructEvent(rawBody, signature, secret) the same way.
Step 2: Lock the plan column
Users may edit their name or avatar. They must not edit their plan.
A simple way: keep paid status in its own table (for example subscriptions) that users can read but not write. Only your webhook writes to it, using the service role key on the server.
alter table public.subscriptions enable row level security;
-- Users can read their own row
create policy "read own subscription"
on public.subscriptions for select
to authenticated
using ((select auth.uid()) = user_id);
-- No insert/update/delete policies for users.
-- The webhook writes with the service role key, on the server only.If your plan column lives in profiles, ask your agent to move it, or to make sure no user policy can change it.
Step 3: Skip duplicate events
Stripe says webhook endpoints "might occasionally receive the same event more than once." It suggests saving the event IDs you've handled and skipping repeats (Stripe: Manage webhook endpoints). Save event.id in a small table before you grant anything.
Step 4: Test the full path
Use Stripe test mode. Pay with Stripe's test card, then check that the plan changed in your database because of the webhook, not because of the success page. Then run Test 3 again. You should get a 400.
If you think your signing secret leaked, Stripe lets you roll it in the Webhooks area of the Dashboard.
Paste this prompt into Lovable, Bolt or Cursor
Make payments in my app server-verified. Keep all features working.
1. Find every place a user's plan, subscription, is_pro or credits is set.
Remove any plan change that runs in the browser (success page, components,
client-side Supabase updates). The success page should only show a
"thanks, we're confirming your payment" message and re-read the plan.
2. Create (or fix) one Stripe webhook endpoint on the server
(Supabase Edge Function or server route). It must:
- read the raw request body (req.text(), not req.json())
- verify the Stripe-Signature header with stripe.webhooks.constructEvent
(or constructEventAsync with a SubtleCryptoProvider in Deno)
and my webhook signing secret from server-only env vars
- return 400 if the signature check fails
- save event.id and skip events it already handled
- only then update the user's subscription using the service role key
3. Store paid status in a table users can read but not write.
Enable RLS. Allow SELECT on their own row only. No user INSERT/UPDATE/DELETE.
4. Make sure no Stripe secret key, webhook secret or service role key is in
frontend code or in VITE_ / NEXT_PUBLIC_ variables.
5. Tell me exactly what changed, and how to test it in Stripe test mode.Quick checklist
- [ ] The success page does not change the plan.
- [ ] A user can't edit their own plan from the browser console.
- [ ] A fake POST to the webhook gets a
400. - [ ] Secrets live only on the server.
- [ ] Duplicate events are skipped.
- [ ] A test-mode payment flips the plan through the webhook.
Related guides
- Is My Lovable App Secure? A 30-Minute Check Before You Launch
- How to Protect Admin Routes and Roles in a Lovable, Bolt or Cursor App
- Can One User See Another User's Data? How to Test Your App
- How to Check if Your Vibe-Coded App Is Leaking API Keys
Sources
- Stripe: Manage webhook endpoints (signatures, raw body, duplicates, rolling secrets)
- Stripe: Webhooks
- Supabase: Handling Stripe Webhooks with Edge Functions
Want a second set of eyes? Run a free VibeVigil scan on your live app. It checks the public side: exposed keys, open Supabase tables, headers, SSL and uptime. It does not test your payment logic, so use the tests above for that.
Scan your app free. It checks the public page of a site you own. No account.