agentleFS
Rikinshah787Rikinshah787/agent-skills-production-skills/skills/stripe/SKILL.md

stripe

Skill2 starsChanged 4 months agoMITView on GitHub

Use to accept payments — Checkout, Payment Intents, subscriptions — and to securely handle webhooks with signature verification.

  • Reads credentials
  • Installs packages

15 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use hubspot and notion.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • refly-aiSkill

    hubspot

    Integrate with HubSpot for CRM management. Use when you need to: (1) manage contacts and deals, (2) track sales pipelines, or (3) automate marketing and CRM workflows.

    Also in 3 projects that use this

  • SentrySkill

    notion

    Search, fetch, create, update, and move Notion pages and data sources. Use when users ask to look up docs, specs, notes, meeting notes, project context, roadmaps, trackers, or internal references stored in Notion, or when they explicitly ask to create or edit Notion content.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 13 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use when: you need one-time payments, subscriptions, or a checkout flow.

    line 21
  2. Distinctive:

    Use when: you must react to payment events (fulfill orders, grant access).

    line 22
  3. Distinctive:

    Don't use for: storing raw card numbers yourself (let Stripe handle PCI scope).

    line 23
  4. Distinctive:

    Verify every webhook signature — otherwise an attacker can POST fake "payment succeeded" events.

    line 124

“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Stripe — Skillship

Accept payments online. The fastest path is Stripe Checkout (a hosted payment page); the durable source of truth for "did they actually pay?" is a webhook you verify with a signature.

🧭 When to use this skill

  • Use when: you need one-time payments, subscriptions, or a checkout flow.
  • Use when: you must react to payment events (fulfill orders, grant access).
  • Don't use for: storing raw card numbers yourself (let Stripe handle PCI scope).

⚡ Quickstart

1. Install

npm install stripe @stripe/stripe-js

2. Configure env (Dashboard → Developers → API keys)

NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...   # safe for the browser
STRIPE_SECRET_KEY=sk_test_...                    # SERVER ONLY — never expose
STRIPE_WEBHOOK_SECRET=whsec_...                  # from `stripe listen` or Dashboard

3. Server client

// lib/stripe.ts
import "server-only";
import Stripe from "stripe";
export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);

🧩 Common recipes

Recipe: Create a Checkout Session (Next.js Route Handler)

// app/api/checkout/route.ts
import { stripe } from "@/lib/stripe";
import { NextResponse } from "next/server";

export async function POST(req: Request) {
  const origin = req.headers.get("origin")!;
  const session = await stripe.checkout.sessions.create({
    mode: "payment", // "subscription" for recurring, "setup" to save a card
    line_items: [{ price: process.env.PRICE_ID!, quantity: 1 }], // never trust client-sent prices
    success_url: `${origin}/success?session_id={CHECKOUT_SESSION_ID}`,
    cancel_url: `${origin}/?canceled=true`,
    automatic_tax: { enabled: true },
  });
  return NextResponse.redirect(session.url!, 303);
}

Always set the amount/price on the server from a trusted price ID — never from the request body.

Recipe: Verify a webhook (this is the important one)

// app/api/webhooks/stripe/route.ts
import { stripe } from "@/lib/stripe";

export async function POST(req: Request) {
  const body = await req.text();                    // RAW body — do not JSON.parse first
  const sig = req.headers.get("stripe-signature")!;
  let event;
  try {
    event = stripe.webhooks.constructEvent(body, sig, process.env.STRIPE_WEBHOOK_SECRET!);
  } catch (err) {
    return new Response(`Webhook Error: ${(err as Error).message}`, { status: 400 });
  }

  // Return 2xx FAST; do heavy work async / idempotently
  switch (event.type) {
    case "checkout.session.completed":
      // fulfill the order — key off event.id to dedupe
      break;
    case "payment_intent.succeeded":
      break;
    default:
      break;
  }
  return new Response(null, { status: 200 });
}

Recipe: Test webhooks locally

stripe login
stripe listen --forward-to localhost:3000/api/webhooks/stripe
# copy the printed whsec_... into STRIPE_WEBHOOK_SECRET
stripe trigger payment_intent.succeeded

Recipe: Test cards

ScenarioCard
Success4242 4242 4242 4242
Requires 3DS auth4000 0025 0000 3155
Declined4000 0000 0000 9995

🚀 Ship to production

  • Switch from sk_test_/pk_test_ to live keys, set in the host secret store.
  • Webhook endpoint is public HTTPS and registered in the Dashboard for the events you need.
  • Signature verification uses the raw request body (disable body parsing / don't JSON.parse first).
  • Handler returns 2xx quickly; fulfillment runs async and is idempotent (dedupe by event.id).
  • Don't assume event ordering; refetch objects via the API when needed.
  • Exempt the webhook route from CSRF protection.
  • Fulfill only after payment success events — never on the client redirect alone.

🔐 Security & secrets

  • STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET are server-only. Never bundle them to the client.
  • Verify every webhook signature — otherwise an attacker can POST fake "payment succeeded" events.
  • Stripe includes a timestamp in the signature (default 5-min tolerance) to block replay attacks; keep server clocks synced (NTP). Never set tolerance to 0.
  • Roll the signing secret periodically or if compromised.

🐛 Common errors & fixes

SymptomLikely causeFix
No signatures found matching the expected signatureBody was parsed/modified before verifyUse the raw body (await req.text()), not parsed JSON
Webhook shows as failed / timeoutDoing heavy work before respondingReturn 200 first, process async
Duplicate fulfillmentStripe retried the eventDedupe by event.id; make handlers idempotent
Order fulfilled but no paymentFulfilling on client redirectFulfill on checkout.session.completed webhook
Invalid API Key providedTest vs live key mismatchMatch key mode to environment

📚 Sources

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.