---
name: "stripe-checkout-webhook-idempotency"
description: "Handle payments, subscriptions, and webhook events safely with signature verification."
metadata:
  author: "Stripe"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "create stripe checkout session"
  - "verify stripe webhook signature"
  - "handle stripe idempotency"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Stripe Checkout & Idempotent Webhook Processing

Integrates Stripe: creating Checkout Sessions (stripe.checkout.sessions.create), verifying raw webhook signatures (stripe.webhooks.constructEvent), handling idempotency (storing processed event IDs), and billing portals.

## When to Invoke
Invoke this skill whenever you need to:
- create stripe checkout session
- verify stripe webhook signature
- handle stripe idempotency

## Execution SOP & Rules
1. Create session: await stripe.checkout.sessions.create({ mode: 'subscription', line_items: [...], success_url, cancel_url }).
2. In webhook route: read raw request body as Buffer; verify: stripe.webhooks.constructEvent(rawBody, sig, secret).
3. Check event deduplication: if (await isEventProcessed(event.id)) return res.json({ received: true }).
4. Handle checkout.session.completed to upgrade user tier and record event.id atomically.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
