Skip to content
Skills Library
Programming · Tool integration

stripe-integration

/stripe-integration

Implements Stripe payments, subscriptions, and webhooks so billing state stays correct - Checkout Sessions, signature-verified idempotent webhook handlers, dunning, and SCA handling. Use when someone asks "add Stripe subscriptions to my app", "why is my webhook signature verification failing", "my database says subscribed but Stripe says canceled", "how do I avoid double-charging on retries", or "how should I handle failed payments". Do NOT use for choosing price points, tiers, or packaging - use saas-pricing instead; for general-purpose webhook receiver hardening beyond Stripe, use webhook-re

Repository
skills ↗
Licence
MIT
Last repository change
13.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 13.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Implements Stripe payments, subscriptions, and webhooks so billing state stays correct - Checkout Sessions, signature-verified idempotent webhook handlers, dunning, and SCA handling. Use when someone asks "add Stripe subscriptions to my app", "why is my webhook signature verification failing", "my database says subscribed but Stripe says canceled", "how do I avoid double-charging on retries", or "how should I handle failed payments". Do NOT use for choosing price points, tiers, or packaging - use saas-pricing instead; for general-purpose webhook receiver hardening beyond Stripe, use webhook-re

Triggers from the description

add Stripe subscriptions to my appwhy is my webhook signature verification failingmy database says subscribed but Stripe says canceledhow do I avoid double-charging on retrieshow should I handle failed payments
Original author description

Implements Stripe payments, subscriptions, and webhooks so billing state stays correct - Checkout Sessions, signature-verified idempotent webhook handlers, dunning, and SCA handling. Use when someone asks "add Stripe subscriptions to my app", "why is my webhook signature verification failing", "my database says subscribed but Stripe says canceled", "how do I avoid double-charging on retries", or "how should I handle failed payments". Do NOT use for choosing price points, tiers, or packaging - use saas-pricing instead; for general-purpose webhook receiver hardening beyond Stripe, use webhook-re

How it works

  1. Core principle
  2. Operating procedure
  3. Worked contrast
  4. Deliverable
  5. Do NOT
  6. Quality bar
  7. Escalation
Original SKILL.md headings · 120 lines, 1,107 words
SKILL.md preview
---
name: stripe-integration
description: Implements Stripe payments, subscriptions, and webhooks so billing state stays correct - Checkout Sessions, signature-verified idempotent webhook handlers, dunning, and SCA handling. Use when someone asks "add Stripe subscriptions to my app", "why is my webhook signature verification failing", "my database says subscribed but Stripe says canceled", "how do I avoid double-charging on retries", or "how should I handle failed payments". Do NOT use for choosing price points, tiers, or packaging - use saas-pricing instead; for general-purpose webhook receiver hardening beyond Stripe, use webhook-receiver-hardener; for idempotency patterns outside payments, use idempotency-enforcer.
metadata:
  title: "Stripe Expert"
---

# Stripe Expert

Billing bugs are the most expensive class of bug: an unverified webhook is an open door to fake "payment succeeded" events, a non-idempotent handler double-provisions on Stripe's at-least-once delivery, and state inferred from a client redirect grants free access to anyone who can type a URL. This skill wires Stripe so money moves correctly and your database never disagrees with Stripe about who has paid.

## Core principle

Stripe is the source of truth for billing state. Your database is a mirror, updated only by verified webhooks. Never grant access from a client-side success callback or redirect - the redirect can be spoofed, dropped, or replayed; the webhook cannot.

## Operating procedure

### Step 1: Gather inputs

1. Billing model - one-time purchase, flat subscription, per-seat, or usage-based? Default for SaaS: flat subscription via Checkout.
2. Existing user model - is there a `stripe_customer_id` column? One Stripe customer per user, created lazily on first purchase.
3. Access-gating point - the exact code path that checks "is this user paid?". It must read your mirrored subscription status, nowhere else.
4. Dunning policy - how many days of grace on `past_due` before access is cut? Default: 7 days with email notices.

### Step 2: Build the purchase flow (Checkout)

1. Create the Checkout Session server-side. Never trust amounts or price IDs from the client - accept only an internal plan identifier and resolve the Stripe price ID server-side.
2. Redirect the customer to the hosted page.
3. Treat the success page as UI only ("thanks, your access is activating"). Entitlement flips when the webhook lands, typically within seconds.

```ts
const session = await stripe.checkout.sessions.create({
  mode: 'subscription',
  line_items: [{ price: priceId, quantity: 1 }],   // resolved server-side
  success_url: `${base}/success?session_id={CHECKOUT_SESSION_ID}`,
  cancel_url: `${base}/pricing`,
  customer: stripeCustomerId,
}, { idempotencyKey: `checkout:${userId}:${planId}` });
```

Pass an `Idempotency-Key` on every create request (sessions, charges, customers) so a network retry cannot create two of anything.

### Step 3: Build the webhook handler against this checklist

Every item is mandatory; each one missing is a specific production incident.

- [ ] Signature verified with `stripe.webhooks.constructEvent(rawBody, sig, endpointSecret)` - reject with 400 on failure. Skipping this lets anyone POST fake payment events.
- [ ] Raw request body used for verification. Body-parsing middleware (e.g. `express.json()`) mutates bytes and breaks the signature - exempt the webhook route.
- [ ] Idempotent: store processed `event.id`s (unique-constrained table) and skip duplicates. Stripe delivers at-least-once; without this, a redelivery double-provisions.
- [ ] Returns 2xx within a few seconds; heavy work (emails, provisioning) goes to a queue. Stripe retries non-2xx responses for up to ~3 days with exponential backoff - a slow handler turns retries into a duplicate storm.
- [ ] Handles out-of-order delivery: apply the event's data (or re-fetch the object from the API) rather than assuming events arrive in sequence.
- [ ] Minimum event set handled: `checkout.session.completed`, `customer.subscription.updated`, `customer.subscription.deleted`, `invoice.payment_failed`.
- [ ] Unhandled event types return 200, not 500 - otherwise Stripe retries events you never intended to process.

### Step 4: Mirror subscription state

On each subscription event, upsert one row per user: `stripe_customer_id`, `stripe_subscription_id`, `status`, `current_period_end`, `price_id`. The access gate reads this row only. States to gate on: `active` and `trialing` get access; `past_due` gets the grace window from Step 1; `canceled` and `unpaid` do not.

### Step 5: Handle failure and lifecycle paths

- `invoice.payment_failed`: start dunning - notify the user, keep access through the grace window, cut on expiry or `subscription.deleted`.
- Declines: catch `StripeCardError` and surface a friendly message. Retry only transient errors (network, 5xx, rate limit); never auto-retry a card decline - that is card-testing behavior and triggers fraud flags.
- SCA/3DS: with Payment Intents, handle `requires_action` by completing authentication client-side. Checkout handles this for you - one more reason to prefer it.
- Plan changes: decide proration explicitly (`proration_behavior`) and communicate the resulting invoice line to the user before confirming.
- Trials: handle `customer.subscription.trial_will_end` (fires 3 days before) to warn the user before the first charge.

### Step 6: Test before going live

Run `stripe listen --forward-to localhost:PORT/webhook` and use test-mode keys. Verify with `stripe trigger`: successful checkout, duplicate event delivery (handler must no-op the second), payment failure, and cancellation. A webhook path that has never seen a replayed event in test will double-provision in production.

## Worked contrast

Bad - grants access from the redirect:

```ts
// success page handler
app.get('/success', async (req, res) => {
  await db.user.update({ where: { id: req.user.id }, data: { plan: 'pro' } }); // spoofable
  res.render('success');
});
```

Good - grants access from the verified, idempotent webhook:

```ts
app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res) => {
  let event;
  try {
    event = stripe.webhooks.constructEvent(req.body, req.headers['stripe-signature'], endpointSecret);
  } catch { return res.status(400).send('bad signature'); }

  const inserted = await db.processedEvents.insertIgnoreDuplicate({ id: event.id });
  if (!inserted) return res.sendStatus(200); // already handled

  if (event.type === 'checkout.session.completed') {
    await queue.enqueue('activate-subscription', event.data.object);
  }
  res.sendStatus(200);
});
```

## Deliverable

Produce a working integration containing: the server-side Checkout Session endpoint with idempotency keys; a webhook handler passing every item on the Step 3 checklist; the mirrored subscription table and the single access-gate read path; the dunning policy wired to `invoice.payment_failed`; and a test log showing duplicate-delivery and failure events handled correctly via the Stripe CLI.

## Do NOT

- Do not gate access on the success redirect - it is spoofable and unreliable; only the verified webhook flips entitlement.
- Do not parse the webhook body before signature verification - verification fails on mutated bytes and you will "fix" it by disabling verification.
- Do not process an event ID twice - at-least-once delivery guarantees you will eventually receive duplicates.
- Do not trust price IDs or amounts from the client - a tampered request buys the enterprise plan at the hobby price.
- Do not auto-retry card declines or create more than one Stripe customer per user.
- Do not do slow work inline in the handler - return 2xx fast, queue the rest.

## Quality bar

- Signature verification on raw body, with a 400 path that is actually exercised in tests.
- Duplicate event delivery proven to no-op in a test run.
- Zero client-supplied amounts or price IDs reach the Stripe API.
- Access gating reads exactly one mirrored status field, and every subscription lifecycle state maps to a defined access decision.
- `stripe listen` test log covers success, duplicate, failure, and cancellation.

## Escalation

This skill covers integration mechanics, not pricing strategy - route tier and packaging questions to saas-pricing. Tax registration, revenue recognition, and regulated money-movement (marketplaces holding funds, Connect platform liability) warrant a payments-savvy accountant or lawyer, not just Stripe defaults.

Versions

RepositoryScoreLicence
This page · SkillMedev/skills100MIT
openaccountants/openaccountants100AGPL-3.0
davila7/claude-code-templates100MIT
rootcastleco/rei-skills100MIT
wshobson/agents100MIT
rmyndharis/antigravity-skills100MIT
HermeticOrmus/LibreUIUX-Claude-Code100MIT
agent-skills-hub/agent-skills-hub100MIT

Database snapshot: 13.11.2026 · package version 0702832e3584 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100stripe-integration-expert
    Implement Stripe integrations for SaaS billing: subscriptions, checkout, proration, usage- based billing, idempotent webhooks, customer portal, dunning, and SCA. Use when building billing, handling webhooks, or testing with Stripe CLI.
  • 90stripe-integration-expert
    Implement Stripe integrations for SaaS billing: subscriptions, checkout, proration, usage- based billing, idempotent webhooks, customer portal, dunning, and SCA. Use when building billing, handling webhooks, or testing with Stripe CLI.
  • 100stripe-developer
    Full-stack Stripe developer skill for building payment integrations with Next.js and Supabase. Covers Checkout (hosted and embedded), Products & Prices, Subscriptions & Billing, Webhooks (signature verification, event handling), Customer Portal, the Stripe Node.js SDK,…
  • 100stripe
    Use when wiring an app to Stripe for payments, subscriptions, Checkout, webhooks or the billing portal — adding a paywall or paid plan, charging recurring fees, and debugging why a completion event never fires, why signature verification fails, or why a webhook fires twice and…
  • 100stripe-subscriptions-webhooks
    Stripe for SaaS in Next.js — Checkout Sessions (subscription mode), Customer Portal, webhook signature verification, idempotency, subscription lifecycle events, multi-currency, Stripe Tax, metered billing, prorations, trial logic, sync to your DB. Use when adding paid plans,…
  • 95stripe-payments
    Use this skill when the user says 'stripe subscription', 'stripe webhook', 'subscription lifecycle', 'stripe billing', 'invoice.paid', 'past_due', 'dunning', 'stripe idempotency key', 'constructEvent'. It designs Stripe Billing subscription flows and production-grade webhook…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.