16-stripe-payments

16-stripe-payments is a cursor rule for Cursor from bybren-llc/safe-agentic-workflow. It costs 0 tokens per session (779 once invoked), scanned A, original, MIT.

A set of rules for integrating Stripe, a service for accepting payments and managing subscriptions. It covers checkout, payment webhooks, recurring billing, duplicate-event protection, and safe use of Stripe's test environment.

In plain words
What is it for?
Use it when building Stripe checkout flows, subscriptions, payment webhooks, or related server-side payment handling.
Why use it?
It helps prevent development work from using live payment credentials or processing the same webhook event twice. It also provides a consistent approach to verifying payment notifications.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/. Also seen: reads .claude/ paths.

Good fit Use it when building Stripe checkout flows, subscriptions, payment webhooks, or related server-side payment handling.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/bybren-llc/safe-agentic-workflow/16-stripe-payments
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/bybren-llc/safe-agentic-workflow

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for 16-stripe-payments

README.md
[![agentmods](https://agentmods.dev/badge/rules/bybren-llc/safe-agentic-workflow/16-stripe-payments.svg)](https://agentmods.dev/rules/bybren-llc/safe-agentic-workflow/16-stripe-payments)
Your own site
<a href="https://agentmods.dev/rules/bybren-llc/safe-agentic-workflow/16-stripe-payments"><img src="https://agentmods.dev/badge/rules/bybren-llc/safe-agentic-workflow/16-stripe-payments.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 779 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00779
Opus 5 $0.00000 $0.00390
Sonnet 5 $0.00000 $0.00156
Haiku 4.5 $0.00000 $0.00078

Measured 4d ago against content hash 257ef238d21b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

16-stripe-payments scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

.cursor/rules/16-stripe-payments.mdc · 118 lines

How it starts

The opening of the file, as written. The whole thing — 118 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Stripe Payment Rules

These rules apply when working on Stripe payment integration, webhooks, checkout flows, or subscription management.

Test Mode Safety (CHECK FIRST)

Before ANY payment work:

  • Verify STRIPE_SECRET_KEY starts with sk_test_
  • Confirm test webhook secret (whsec_... from Stripe CLI)
  • Use test card numbers only (4242 4242 4242 4242)
  • Never use production keys in development

Webhook Handler Pattern

ALWAYS verify webhook signatures and handle idempotency:

import stripe
from fastapi import Request, HTTPException

async def handle_stripe_webhook(request: Request):
    payload = await request.body()
    signature = request.headers.get("stripe-signature")

    try:
        event = stripe.Webhook.construct_event(
            payload, signature, settings.STRIPE_WEBHOOK_SECRET
        )
    except stripe.error.SignatureVerificationError:
        raise HTTPException(status_code=400, detail="Invalid signature")

    # Idempotency: check if event already processed
    existing = await get_webhook_event(event.id)
    if existing:
        return {"status": "already_processed"}

    # Process event and record
    await process_event(event)
    await record_webhook_event(event.id, event.type)
    return {"status": "processed"}

Idempotency Checklist

For ALL webhook handlers:

  • Store event ID before processing
  • Check for duplicate events before processing
  • Use database transactions for atomicity
  • Return 200 OK even on idempotency skip (Stripe retries on non-200)

Common Webhook Events

SUBSCRIPTION_EVENTS = [
    "customer.subscription.created",
    "customer.subscription.updated",
    "customer.subscription.deleted",
    "invoice.payment_succeeded",
    "invoice.payment_failed",
]

Local Webhook Testing

Use the Stripe CLI to forward events locally:

# Start webhook forwarding
stripe listen --forward-to localhost:8000/api/v1/webhooks/stripe

# Trigger test events
stripe trigger checkout.session.completed
stripe trigger invoice.payment_succeeded
stripe trigger customer.subscription.deleted

Read the full file on GitHub · 118 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 118 lines · 0 tokens per session scan A 257ef238d21b

Subscribe to this mod's changes

16-stripe-payments is a cursor rule published in the GitHub repository bybren-llc/safe-agentic-workflow (406 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 779 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.