Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 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.

    Requires Node.js 20+ and stripe-node 23. Examples are tailored for Next.js 16 and Postgres/Supabase. Does not support legacy API versions prior to 2026-09-30.endive.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by 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 scan

    Security scan passed 1 month ago

    Requires

    tsx
    Node.js

    Permissions

    Environment Variables
    Terminal / Shell
    Read Files
    Network Access
    Listed1 month ago

    What's inside

    Frequently Asked Questions

    This skill provides a production-ready architectural framework for Stripe, specifically handling complex logic like idempotent webhook synchronization, database state locking, and modern API version pinning that generic prompts often get wrong.

    It is optimized for Node.js 20+, Next.js 16 (App Router), and Postgres/Supabase, and it requires the stripe-node v23 SDK to function as intended.

    Yes, the skill includes specialized logic for usage-based meters, automatic tax collection, and dunning cycles to ensure your SaaS can scale beyond simple flat-rate subscriptions.

    The skill provides a specialized router and a two-stage checklist system (pre-flight and go-live) to guide you through secure session creation and verified webhook implementation.

    A test clock simulation script for renewals, trials and failed payments, test card scenarios, a stripe-mock setup for CI, a webhook probe that sends signed, forged, stale and duplicate deliveries, and a pre-launch matrix to run before switching to live keys.

    By using idempotent webhook handlers and advisory locks, the skill ensures your Postgres database accurately reflects the subscription state even if Stripe sends multiple events or if network latency occurs.

    New in APIs & Backend