stripe-one-time-payment-webhooks
Skill10 starsChanged 6 months agoMITView on GitHub
Use when webhooks for one-time Stripe payments: Checkout mode payment, Payment Links, payment_intent.succeeded, orders table, credits, or lifetime purchases. Not for recurring subscriptions (use stripe-payment-webhooks and pricing-and-billing).
In this repository56 other files it gives its agents.
- accessibility-passSkill
- analytics-eventsSkill
- api-error-handlingSkill
- audit-logging-backendSkill
- background-jobs-and-cronSkill
- dark-mode-and-themingSkill
- dashboard-charts-rechartsSkill
- edge-functions-and-webhooksSkill
- email-and-notificationsSkill
- error-states-and-empty-uiSkill
- feature-flags-and-togglesSkill
- file-upload-storageSkill
- i18n-multi-languageSkill
- lovable-prompting-playbookSkill
- lovable-ship-checklistSkill
- migration-playbookSkill
- multi-tenant-backendSkill
- onboarding-copySkill
- optimistic-updatesSkill
- payment-failed-and-recoverySkill
- payment-webhook-idempotencySkill
- payment-webhook-testingSkill
- performance-budgetSkill
- pg-cron-recipesSkill
- pg-cron-scheduled-jobsSkill
- pg-cron-with-pg-net-edgeSkill
- postgres-full-text-searchSkill
- postgres-triggers-and-functionsSkill
- pricing-and-billingSkill
- programmatic-seo-content-qualitySkill
- programmatic-seo-pagesSkill
- rate-limiting-edgeSkill
- realtime-and-subscriptionsSkill
- refactor-safe-diffSkill
- release-notesSkill
- seo-core-web-vitalsSkill
- seo-landing-pageSkill
- seo-meta-tags-spaSkill
- seo-sitemap-generationSkill
- seo-ssr-and-prerenderingSkill
- seo-structured-dataSkill
- server-input-validationSkill
- shadcn-patternsSkill
- soft-delete-and-archivingSkill
- stripe-payment-webhooksSkill
- supabase-auth-flowsSkill
- supabase-database-designSkill
- supabase-rls-and-authSkill
- support-replySkill
- tanstack-infinite-queriesSkill
- tanstack-mutations-and-invalidationSkill
- tanstack-prefetch-and-hydrationSkill
- tanstack-query-alternativeSkill
- tanstack-router-data-loadersSkill
- tanstack-start-server-routesSkill
- typed-api-hooks-formsSkill
The file
Files
Stripe one-time payment webhooks
Separate orders / purchases from subscriptions. Different events and tables.
Checkout mode: "payment"
Handle checkout.session.completed:
session.mode === "payment"session.payment_intent— retrieve for amount, statusclient_reference_id/metadata.user_id→ app user
case "checkout.session.completed": {
const session = event.data.object as Stripe.Checkout.Session;
if (session.mode !== "payment") break;
const userId = session.client_reference_id ?? session.metadata?.user_id;
if (!userId || !session.payment_intent) break;
await upsertOrder({
user_id: userId,
stripe_payment_intent_id: session.payment_intent as string,
stripe_checkout_session_id: session.id,
amount_total: session.amount_total,
currency: session.currency,
status: "paid",
});
break;
}Also handle payment_intent.succeeded if you create PaymentIntents without Checkout — same upsert keyed on payment_intent.id (idempotency).
Schema
create table public.orders (
id uuid primary key default gen_random_uuid(),
user_id uuid not null references auth.users(id),
stripe_payment_intent_id text unique,
stripe_checkout_session_id text unique,
amount_total bigint,
currency text,
status text not null check (status in ('paid', 'refunded', 'failed')),
product_id text,
created_at timestamptz default now()
);Refunds
charge.refundedorpayment_intent.canceled→ setorders.status = 'refunded'; revoke credits if applicable.
Credits / lifetime license
Grant in webhook after idempotency check:
await supabase.rpc("grant_credits", { p_user_id: userId, p_amount: 100 });RPC must be idempotent or guarded by stripe_payment_intent_id unique constraint.
Avoid
- Storing one-time purchase only in
subscriptionstable. - Fulfilling order on
success_urlwithout webhook. - Double grant on
checkout.session.completed+payment_intent.succeededwithout shared idempotency key (use samepayment_intent_idunique key).
Related
stripe-payment-webhooks— signature and hostingpayment-webhook-idempotency— duplicate events
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

