Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+22 more

    Stripe SaaS Billing Pack

    1

    Eight agent skills that build Stripe subscriptions correctly on stripe-node 23: Checkout, portal, webhooks, DB sync, entitlements, usage, tax, dunning, tests.

    $29

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Stripe SaaS Billing Pack

    Stripe SaaS Billing Pack

    Example session with this skill installed

    Add a Pro subscription to our Next.js app. Users must get access only after Stripe confirms it, and it has to survive webhook retries.

    • Read your context and instructions
    • Compiled the stripe saas billing

    Summary

    Checkout route, signed webhook handler and a database sync that ignores duplicates and out-of-order events. Access comes from the database, never from the success page.

    Checkout route

    src/app/api/billing/checkout/route.ts

    export async function POST(request: Request) {
      const user = await requireUser();
      const form = await request.formData();
      const lookupKey = String(form.get('lookup_key') ?? '');
      if (await activeSubscriptionId(user.id)) {
        return Response.redirect(`${APP_URL}/api/billing/portal`, 303);
      }
      const prices = await stripe.prices.list({ lookup_keys: [lookupKey], active: true, limit: 1 });
      const price = prices.data[0];
      if (!price) return Response.json({ error: 'Unknown plan' }, { status: 400 });
      const customer = await getOrCreateCustomer(user);
      const session = await stripe.checkout.sessions.create({
        mode: 'subscription',
        customer,
        client_reference_id: user.id,
        line_items: [{ price: price.id, quantity: 1 }],
        subscription_data: { trial_period_days: 14, metadata: { user_id: user.id } },
        allow_promotion_codes: true,
        success_url: `${APP_URL}/billing/success?session_id={CHECKOUT_SESSION_ID}`,
        cancel_url: `${APP_URL}/pricing`,
      });
      if (!session.url) return Response.json({ error: 'No Checkout URL' }, { status: 500 });
      return Response.redirect(session.url, 303);
    }
    

    Webhook route

    src/app/api/stripe/webhook/route.ts

    export async function POST(request: Request) {
      const signature = request.headers.get('stripe-signature');
      const secret = process.env.STRIPE_WEBHOOK_SECRET;
      if (!signature || !secret) return new Response('Missing signature', { status: 400 });
      const body = await request.text();
      let event: Stripe.Event;
      try {
        event = stripe.webhooks.constructEvent(body, signature, secret);
      } catch {
        return new Response('Invalid signature', { status: 400 });
      }
      try {
        await handleStripeEvent(event);
      } catch (err) {
        return new Response('Handler error', { status: 500 });
      }
      return new Response(null, { status: 200 });
    }
    

    Sync rules

    EventHandling
    Already in stripe_eventsSkipped, so retries are no-ops
    checkout.session.completed, customer.subscription.*syncSubscription(id) under pg_advisory_xact_lock, re-fetched from Stripe
    invoice.paid, invoice.payment_failedRead invoice.parent.subscription_details.subscription, not the removed invoice.subscription
    AccessRead from a billing_access view: active, trialing, past_due

    Next steps

    stripe listen --forward-to localhost:3000/api/stripe/webhook --latest
    node webhook-doctor.mjs probe --url http://localhost:3000/api/stripe/webhook --secret whsec_...
    node webhook-doctor.mjs scan ./src
    

    The probe must pass all six checks (valid, valid pretty-printed, forged, unsigned, stale, duplicate).

    Connects securely to your tools. The creator never sees your data.

    About this skill

    AI agents write Stripe code from 2023. On today's stripe-node 23 and API 2026-09-30.endive that code fails: payment_method_types: ['card'] is rejected, require('stripe')(key) no longer constructs a client, subscription.current_period_end is undefined, ui_mode: 'hosted' errors, createUsageRecord is gone. Worse, the parts that compile are wrong in production: access granted on the success page, webhook handlers that parse JSON before verifying the signature, no dedupe, a late customer.subscription.created overwriting a cancellation, a staging endpoint on invoice.created that delays every renewal by 72 hours.

    This pack gives the agent the current rules and working code, checked against the Stripe API changelog, docs.stripe.com and the stripe-node 23 types, typechecked with tsc --strict and run against stripe-mock and Postgres.

    What's inside

    • stripe-saas-billing: architecture, pre-flight questions, go-live checklist, routing.
    • stripe-node-current: v21, v22, v23 breaking changes and every billing API change since basil.
    • stripe-subscriptions-checkout: catalog with lookup keys, Checkout Session route, success page, customer portal as code, trials, proration previews, downgrades at period end, cancel, pause.
    • stripe-webhooks-prod: raw-body verification for Next.js App Router, Pages Router, Express, Fastify, Hono and Workers, the events a SaaS must handle, dedupe, ordering, retries, thin events, stripe listen.
    • stripe-subscription-sync: Postgres schema, fetch-latest sync under advisory locks, entitlements, access per status, Supabase RLS, nightly reconciliation.
    • stripe-usage-billing: Billing Meters vs Metronome, metered prices, idempotent meter events, v2 streams.
    • stripe-tax-dunning: Stripe Tax without the silent zero-tax trap, Smart Retries, hard declines, recovery emails, past_due UX.
    • stripe-billing-testing: test clock simulation script, test cards, stripe-mock CI, pre-launch matrix.

    Scripts included

    webhook-doctor.mjs probes a running endpoint with signed, forged, stale and duplicate deliveries and scans a codebase for missing lifecycle events and stale API usage. sync-check.mjs diffs your subscription table against Stripe and flags access leaks. Both are zero-dependency Node.

    Versions

    stripe-node 23.x (API 2026-09-30.endive), Node.js 20+, Next.js 16, Postgres. Works with Claude Code, Codex, Gemini CLI and Cursor.

    How to use

    Skills on Agensi run inside your AI agent. Copy the prompt, paste it into your agent, and it connects to Agensi and installs this skill for you. If a payment is needed, your agent shows it to you first.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill passes our trust checks below.

    Security scanned

    Passed our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scanned

    Verified clean 6 days ago

    • Passed all security checks, Safe to install

    Requires

    tsx
    Node.js

    Listed6 days ago

    What's inside

    Frequently Asked Questions