Stripe Payments on Vercel + Supabase, Done Safely
Published
Tested drop-in code, SQL and checks for taking subscriptions and credit-pack payments with Stripe in a Next.js + Supabase app: verified webhooks, no double-granting, users who can't edit their own billing rows, and a test-mode-first path to going live.
Download free (.zip)Feedback / Report a problemFree, no sign-up. Want the week's best kits by email? Get the weekly roundup (optional).
What's in the kit
app/api/stripe webhook, checkout and portal routes and 8 lib/billing TypeScript files (Next.js App Router, stripe-node 23, @supabase/ssr), supabase/billing.sql and billing-selfcheck.sql, webhook-selftest.mjs and check-stripe-env.mjs (no installs), a Cursor .mdc rule and a Claude Code / AGENTS.md rule, env.example.txt, use-test-mode and go-live checklists, step-by-step setup for Supabase, Stripe, local testing and Vercel, examples (buttons, billing page, spending credits, subscriber-only RLS), troubleshooting and sources.
- Next.js route templates for the Stripe webhook, Checkout and customer portal, with the signature check, duplicate and out-of-order handling already done
- A Supabase migration for subscriptions and credits with Row Level Security, plus a read-only self-check that flags each unsafe change
- A webhook self-test script that sends six fakes and one real-style signed event to your endpoint
- An env checker that catches live keys in dev, secrets in NEXT_PUBLIC_ variables, mixed test/live keys and committed .env files
- Cursor and Claude Code rules that stop your AI from trusting browser prices or granting access on the success page
- Test-mode-first and go-live checklists
Free sample: The test-mode checklist
Copy it right here, or download the whole kit above. This is the actual text from the kit.
# Test-mode-first checklist Do all of this in a Stripe **sandbox** (test mode) before any live key exists in your project. Tick each line yourself; "the AI said it works" doesn't count. ## Keys and settings - [ ] Stripe Dashboard is on your sandbox (test mode). Your keys start with `sk_test_` / `rk_test_` and `pk_test_`. - [ ] `.env.local` has the variables from `env.example.txt`, and `.gitignore` contains `.env*`. - [ ] `node scripts/check-stripe-env.mjs` says **No problems found**. - [ ] Supabase: `supabase/billing.sql` ran, and `supabase/billing-selfcheck.sql` shows **only PASS** lines. ## Webhook - [ ] `stripe listen --events <the 7 events> --forward-to localhost:3000/api/stripe/webhook` is running, and `STRIPE_WEBHOOK_SECRET` in `.env.local` is the `whsec_` it printed. Restart `npm run dev` after changing it. - [ ] `node scripts/webhook-selftest.mjs http://localhost:3000/api/stripe/webhook` shows **7 PASS**. ## Buy things with test cards (setup/03-test-locally.md has the exact steps) - [ ] Subscribe with `4242 4242 4242 4242` -> a row appears in `subscriptions` with status `active`, and your paid page unlocks. - [ ] Cancel in the customer portal (immediately) -> the row becomes `canceled`, and the paid page locks again. - [ ] Buy the credit pack -> `credit_balances` goes up by exactly 100. In the Stripe Dashboard, resend that `checkout.session.completed` event -> the balance does **not** change. - [ ] Declined card `4000 0000 0000 0002` -> no row, no credits, and the Checkout page shows the error. - [ ] 3D Secure card `4000 0027 6000 3184` (always asks for authentication) -> completing the challenge works; failing it grants nothing. - [ ] Close the tab right after paying (before the success page) -> access/credits still arrive (the webhook did it). - [ ] Signed in as user B, you can't see user A's subscription or credits (try it in the Supabase API or your app). ## Your own code - [ ] Paid features check the database (`getBillingState()` or an RLS policy using `is_subscriber()`), not a flag in the browser or the success URL. - [ ] Anything that spends credits calls `billing_spend_credits` on the server and handles `false` (not enough credits).
Questions about this kit
Is the Stripe Payments on Vercel + Supabase, Done Safely kit free?
Yes. It's a free .zip download ($0) with no account and no email required. Bot Pantry is paid for by clearly labeled sponsors, not by selling kits.
Who is this kit for?
Beginners and vibe coders with a Next.js App Router app on Vercel and Supabase Auth who want to add Stripe subscriptions or one-time credit packs without the usual AI-generated payment holes.
Which tools does it work with?
It's written for: Cursor; Claude Code; v0; Stripe; Supabase; Vercel; Next.js; Node.js 20+. The kit is a .zip of files (prompts, templates, guides and checklists) that you use with those tools. Bot Pantry has no app or account to sign up for.
How long does setup take?
About 60-120 min. That setup time was checked when the kit was reviewed before publishing.
How do I start?
Download the .zip, unzip it and open README.md first. It explains what each file is for and walks you through setup (about 60-120 min). The free sample above is a real file from the kit.
Will the AI act on its own?
No. Like every Bot Pantry kit, it is set up so the AI drafts or suggests and you decide. It should not send, post, delete or spend anything on its own.
More free kits for vibe coders
Free AI agent kits for vibe coders · Browse the full kit library
Where this kit fits: Vibe coding launch checklist: 4 free kits, in order