agentleFS
salmandevsalmandev/everything-gemini/skills/stripe-integration/SKILL.md

stripe-integration

Skill2 starsChanged 28 days agoApache-2.0View on GitHub

Use this skill when implementing Stripe checkout sessions, managing subscription billing lifecycles, verifying webhook signatures, or configuring customer billing portals.

  • Reads credentials

13 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never process webhooks without verifying the cryptographic signature against your endpoint secret:

    line 15
  2. Very specific:

    Always store event.id in an idempotency_keys table or set a unique constraint.

    line 49
  3. Very specific:

    Use client_reference_id or metadata to link Stripe customers with your internal user IDs.

    line 50

“Common” is measured: kept by at least 6 in 10 of the 12 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 Payments & Subscription Architecture

Overview

This skill guides the implementation of PCI-compliant payment flows, webhook signature verification, idempotent charge processing, and customer portal session generation using the official Stripe SDK.

Procedural Workflow

1. Robust Webhook Signature Verification

Never process webhooks without verifying the cryptographic signature against your endpoint secret:

import Stripe from "stripe";

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
  apiVersion: "2024-06-20",
});

export async function handleStripeWebhook(rawBody: string | Buffer, signature: string) {
  let event: Stripe.Event;
  try {
    event = stripe.webhooks.constructEvent(
      rawBody,
      signature,
      process.env.STRIPE_WEBHOOK_SECRET!
    );
  } catch (err: any) {
    throw new Error(`Webhook signature verification failed: ${err.message}`);
  }

  // Handle idempotent events using database transaction
  switch (event.type) {
    case "checkout.session.completed":
      await handleCheckoutCompleted(event.data.object as Stripe.Checkout.Session);
      break;
    case "customer.subscription.updated":
    case "customer.subscription.deleted":
      await syncSubscriptionStatus(event.data.object as Stripe.Subscription);
      break;
  }
}

2. Idempotency & Concurrency Safety

  • Always store event.id in an idempotency_keys table or set a unique constraint. If Stripe retries a webhook, discard duplicates immediately.
  • Use client_reference_id or metadata to link Stripe customers with your internal user IDs.

3. Customer Billing Portal

Generate pre-authenticated portal sessions so users can update payment methods and invoices self-service without custom frontend form logic:

const portalSession = await stripe.billingPortal.sessions.create({
  customer: stripeCustomerId,
  return_url: `${process.env.NEXT_PUBLIC_APP_URL}/dashboard/billing`,
});

Verification Checklist

  • Raw body buffer preserved for webhook cryptographic verification
  • Idempotency key checked before applying database mutations
  • Webhook handler returns HTTP 200 promptly before long-running async tasks
  • Stripe secret keys read strictly from environment variables

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.