borghei/Claude-Skills / engineering/stripe-integration-expert
stripe-integration-expert
VerifiedImplement 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.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 9.3 KB |
| assets/sample_project_flawed/stripe_webhook.ts | script | 829 B |
| assets/sample_project_sound/stripe_webhook.ts | script | 2.1 KB |
| references/payment-flows.md | markdown | 4.7 KB |
| references/subscriptions.md | markdown | 9.0 KB |
| references/testing-and-troubleshooting.md | markdown | 4.7 KB |
| references/webhooks.md | markdown | 6.4 KB |
| scripts/checkout_scaffolder.pyexecutable | script | 24.9 KB |
| scripts/integration_auditor.pyexecutable | script | 16.3 KB |
| scripts/webhook_validator.pyexecutable | script | 15.6 KB |
assets/sample_project_sound/stripe_webhook.ts
View on GitHub// Sound sample: verified signature, event dedup, re-fetch, 500 on failure so Stripe retries.
import Stripe from "stripe";
import { db } from "./db";
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, { apiVersion: "2026-10-28.endive" /* pin to the version your SDK ships with */ });
const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET!;
export async function POST(req: Request) {
const body = await req.text();
const signature = req.headers.get("stripe-signature")!;
let event: Stripe.Event;
try {
event = stripe.webhooks.constructEvent(body, signature, webhookSecret);
} catch {
return new Response("bad signature", { status: 400 });
}
// Idempotency: skip events we have already processed
const seen = await db.processedEvent.findUnique({ where: { id: event.id } });
if (seen) return new Response("duplicate", { status: 200 });
try {
switch (event.type) {
case "checkout.session.completed":
case "customer.subscription.created":
case "customer.subscription.updated":
case "customer.subscription.deleted":
case "invoice.payment_succeeded":
case "invoice.payment_failed":
await syncFromStripe(event);
break;
}
await db.processedEvent.create({ data: { id: event.id } });
} catch (err) {
console.error("webhook processing failed", event.id, err);
return new Response("retry", { status: 500 });
}
return new Response("ok", { status: 200 });
}
export async function createCheckout(customerId: string, userId: string) {
try {
return await stripe.checkout.sessions.create(
{
customer: customerId,
mode: "subscription",
line_items: [{ price: process.env.STRIPE_PRICE_PRO!, quantity: 1 }],
metadata: { userId },
success_url: "https://example.com/ok",
},
{ idempotencyKey: `checkout-${userId}` },
);
} catch (err) {
console.error("checkout failed", err);
throw err;
}
}
async function syncFromStripe(event: Stripe.Event) {
// Re-fetch the object instead of trusting the event payload ordering
const obj = event.data.object as { id: string };
return obj.id;
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |