/engineering:stripe-paymentsfrom engineering
Guides Stripe one-time payment integration: PaymentIntents, SetupIntents, Checkout, SCA/3D Secure, multi-currency, idempotency, and webhook hardening.
Ships in engineering. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
| Input | Required | Use |
|---|---|---|
| Tenant, product, and lifecycle scope | yes | Bound the SaaS decision |
| Current architecture, plans, policies, and constraints | yes | Preserve enforceable behaviour |
| Production data or verified evidence | conditional | Validate thresholds and migrations |
Skill-specific inputs:
Default to read-only analysis. Change configuration, billing, identity, tenant data, infrastructure, or customer communications only with explicit authority, least-privilege credentials, tenant scope, rollback, and auditable approval. Never expose secrets or cross tenant boundaries.
If production access, policy, telemetry, or authoritative records are unavailable, produce a labelled design or dry-run plan. Do not claim deployment, reconciliation, deletion, delivery, or measured outcomes; list missing evidence and verification.
| Condition | Action | Stop condition |
|---|---|---|
| Tenant isolation, money, identity, or deletion is affected | Require approval and rollback evidence | Scope or authority is ambiguous |
| Evidence supports a reversible change | Stage, test, and record it | Acceptance checks fail |
| Only partial context is available | Return assumptions and validation | A production claim cannot be verified |
subscription-billing.SKILL.md end-to-end, then load referenced deep-dives only as needed.event.id idempotency.Idempotency-Key.event.id.decimal_digits helper, never hard-coded * 100.Charge API for new code instead of PaymentIntent.2xx from the webhook only after heavy work completes (causes retries on timeout).* 100 for amounts, breaking JPY, KRW, UGX, and other zero-decimal currencies.references/ directory for deep walkthroughs after reading the core workflow below.| Category | Artifact | Format | Example |
|---|---|---|---|
| Correctness | Payment lifecycle reconciliation | Markdown plus webhook fixtures | intent, idempotency, webhook, invoice, refund/dispute, ledger handoff, and retry |
Use this skill when Stripe is the payment rail. The goal is safe, retriable, webhook-driven payments that survive replays, partial failures, and SCA challenges.
world-class-engineeringweb-app-security-audit, api-design-first, cicd-devsecops (for HTTPS, idempotent endpoints, Vault-managed keys)subscription-billing for recurring billing, dunning, metering, and revenue opsobservability-monitoring for PaymentIntent dashboards and webhook lag alertsStripe documents three primary ways to accept payments on a website:
Stripe's official guidance for new builds: prefer the Checkout Sessions API with the Payment Element over direct Payment Intents for most integrations. Use raw Payment Intents only when explicitly required. Source: docs.stripe.com/payments, docs.stripe.com/payments/accept-a-payment.
Only the objects needed for one-time and saved-card flows. Recurring entities live in subscription-billing.
Customer ──► PaymentMethod
│ │
└── PaymentIntent / SetupIntent ──► Charge
(Checkout Session wraps either)
| Model | What you build | Card data lives | Complexity | Pick when |
|---|---|---|---|---|
| Stripe-hosted Checkout | Redirect link or button | Stripe (lowest PCI scope) | 2/5 | Fastest path, standard pricing pages |
| Embedded Checkout | Stripe-hosted form mounted in your DOM | Stripe (low PCI scope) | 2/5 | Want Checkout's logic but stay on-domain |
| Checkout Sessions + Payment Element | Custom form using Stripe UI components | Stripe (PCI SAQ A) | 3/5 | Custom UX, multiple payment methods, design control |
| Payment Intents API direct | Hand-built confirmation flow | Stripe via Elements | Highest | Only when explicitly required |
Source: Stripe "Accept a payment" guide.
Runtime: PHP 7.2+. Install:
composer require stripe/stripe-php
require_once 'vendor/autoload.php';
$stripe = new \Stripe\StripeClient(getenv('STRIPE_SECRET_KEY'));
Customer creation (verbatim shape from stripe-php README):
$customer = $stripe->customers->create([
'description' => 'example customer',
'email' => '[email protected]',
'payment_method' => 'pm_card_visa',
]);
PaymentIntent creation. Required: amount (smallest currency unit) and currency. Common optional: customer, payment_method, confirm, off_session, automatic_payment_methods, setup_future_usage.
$paymentIntent = $stripe->paymentIntents->create([
'amount' => 1999, // $19.99 in smallest currency unit
'currency' => 'usd',
'customer' => $customer->id,
'automatic_payment_methods' => ['enabled' => true],
], ['idempotency_key' => $uuidV4]);
Save-a-card flow: create a SetupIntent, confirm it client-side with Elements, then later create a PaymentIntent with customer, payment_method set to the saved method, plus off_session: true and confirm: true.
Full integration walkthrough: references/stripe-php-integration.md.
Runtime: all LTS versions of Node.js 18+. Install:
npm install stripe
Customer creation, ESM / TypeScript (verbatim from stripe-node README):
import Stripe from 'stripe';
const stripeClient = new Stripe(process.env.STRIPE_SECRET_KEY!);
const customer = await stripeClient.customers.create({
email: '[email protected]',
});
PaymentIntent:
const intent = await stripeClient.paymentIntents.create(
{
amount: 1999,
currency: 'usd',
customer: customer.id,
automatic_payment_methods: { enabled: true },
},
{ idempotencyKey: crypto.randomUUID() },
);
Full integration walkthrough: references/stripe-nodejs-integration.md.
Webhooks are the durable source of truth for payment state. Polling is a bug.
Endpoint requirements (per docs.stripe.com/webhooks):
whsec_*).Signature verification. Use the SDK helper rather than implementing HMAC manually:
\Stripe\Webhook::constructEvent($payload, $sigHeader, $endpointSecret)stripe.webhooks.constructEvent(payload, sigHeader, endpointSecret)The verifier needs the raw request body. In Express, mount express.raw({ type: 'application/json' }) only on the webhook route. In Fastify, register a buffer parser. In PHP, read file_get_contents('php://input') before any framework body parsing.
Manual verification reference (only if no SDK):
t= (timestamp) and v1= (signature) from the Stripe-Signature header.timestamp + '.' + raw_body.v1 signature.Retry semantics (Stripe-side):
Idempotency at the receiver. Persist event.id in MySQL with a unique index. Insert the event row and commit the side effect in the same transaction so replays no-op cleanly.
CREATE TABLE stripe_processed_events (
event_id VARCHAR(255) PRIMARY KEY,
event_type VARCHAR(100) NOT NULL,
received_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
processed_at TIMESTAMP NULL,
payload_hash CHAR(64) NOT NULL,
INDEX idx_event_type (event_type, received_at)
);
Combine event.type with data.object.id to identify duplicates that span event IDs (e.g. retried charge attempts).
Idempotency at the sender. Send an Idempotency-Key HTTP header on every POST. Stripe stores the first response's status and body for that key and errors if subsequent requests arrive with mismatched parameters. Use V4 UUIDs (max 255 chars). Stripe may garbage-collect keys after 24 hours.
Common event types to subscribe to:
payment_intent.succeeded, payment_intent.payment_failed, payment_intent.requires_action, payment_intent.processing, payment_intent.canceledcheckout.session.completedinvoice.paid, invoice.payment_failed, invoice.finalized, invoice.upcomingcustomer.subscription.* (delegate handling to subscription-billing)Full event catalogue and handler patterns: references/webhook-handling.md.
Stripe requires Strong Customer Authentication in regulated regions; SCA "requires customers to use two-factor authentication like 3D Secure to verify their purchase." The Payment Intents API surfaces this via the requires_action status.
PaymentIntent status enum: requires_payment_method, requires_confirmation, requires_action, processing, succeeded, canceled.
On-session vs off-session (Stripe phrasing):
Rules:
setup_future_usage: 'off_session' on the PaymentIntent.off_session: true and confirm: true.requires_action on an off-session attempt, your dunning logic must email the customer back to authenticate. Hand recovery flows to subscription-billing when this happens inside a renewal cycle.Stripe supports charging "in over 135 currencies."
If presentment differs from settlement, Stripe converts at deposit time, typically with a 1% FX spread.
Zero-decimal currencies (JPY, KRW, UGX, VND, RWF, and others): the amount value is the actual amount, not minor units. To charge 500 JPY, send amount: 500. For two-decimal currencies, multiply by 100 (10 USD → 1000).
Ship a helper that maps ISO currency to its decimal_digits rather than hard-coding * 100:
const ZERO_DECIMAL = new Set(['BIF','CLP','DJF','GNF','JPY','KMF','KRW','MGA','PYG','RWF','UGX','VND','VUV','XAF','XOF','XPF']);
export function toMinorUnits(amount: number, currency: string): number {
const code = currency.toUpperCase();
return ZERO_DECIMAL.has(code) ? Math.round(amount) : Math.round(amount * 100);
}
Stripe Tax automates "sales tax, VAT, and GST compliance on all your transactions" and "handles tax obligation monitoring, registrations, calculations, collections, and filings." It also tracks sales against local registration thresholds and alerts when obligations form.
Enable on a Checkout Session or Subscription:
curl https://api.stripe.com/v1/subscriptions \
-u "$STRIPE_SECRET_KEY:" \
-d "automatic_tax[enabled]=true"
Validate customer location at creation: -d "tax[validate_location]=immediately".
Tax IDs. Customers can store country-specific Tax IDs (eu_vat, gb_vat, au_abn, and 200+ types). Collect them at Checkout via tax_id_collection: { enabled: true } and persist via customers.createTaxId. For B2B with valid IDs, Stripe applies reverse-charge automatically where applicable.
Test card matrix (success cases):
| Brand | Number | CVC |
|---|---|---|
| Visa | 4242 4242 4242 4242 | any 3 digits |
| Mastercard | 5555 5555 5555 4444 | any 3 digits |
| American Express | 3782 822463 10005 | any 4 digits |
| Discover | 6011 1111 1111 1117 | any 3 digits |
| Diners Club | 3056 9300 0902 0004 | any 3 digits |
| JCB | 3566 0020 2036 0505 | any 3 digits |
All accept any future expiration date. Sandbox mode is isolated; test-key transactions don't move funds.
Decline / authentication cards: 4000 0025 0000 3155 (3DS required), 4000 0000 0000 0002 (generic decline), 4000 0000 0000 9995 (insufficient funds), 4000 0000 0000 0341 (attach succeeds, first off-session charge fails). Pull the full table from docs.stripe.com/testing when authoring decline tests.
Stripe CLI for local webhooks:
stripe login
stripe listen --forward-to localhost:4242/webhook
stripe trigger payment_intent.succeeded
stripe trigger invoice.payment_failed
The CLI prints a webhook signing secret on first run; pass it as the endpoint_secret argument to the SDK verification helper.
cicd-devsecops runbook; never in committed .env.rak_*) used for read-only or scoped integrations; full secret keys live only in admin operations.event.id persisted with a unique index in MySQL; side-effect commit in the same transaction.Idempotency-Key (V4 UUID) on every server-side paymentIntents.create call.observability-monitoring).toMinorUnits(), not * 100.Security. Never store raw card data; use Stripe-hosted collection or Elements. Keep secret keys server-side only. Verify every webhook signature and reject unsigned payloads. Stripe's redirect and hosted-field model keeps card data off your servers, limiting PCI scope to SAQ A.
Data and state. Stripe object IDs map to internal customer and entitlement records. Access derives from PaymentIntent and Invoice state through verified events. Refunds and cancellations update internal state through durable transitions, never optimistic writes.
UX. Tell the user whether payment is pending, requires action, failed, or complete. Surface SCA prompts immediately. Offer self-service payment-method updates.
Operations. Log Stripe request IDs, webhook event IDs, and internal correlation IDs together. Keep a replay-safe processor and a manual reprocess path. Emit release markers around payment-flow changes.
requires_action and async completion.confirm: true.Idempotency-Key (V4 UUID).event.id + unique index.decimal_digits helper.subscription-billing — recurring billing, plan changes, dunning, proration, metered usage, revenue recognition, customer portal.saas-accounting-system — double-entry posting of Stripe settlements, refunds, FX conversions.ai-saas-billing — AI module gating and per-tenant token metering on top of Stripe.web-app-security-audit — payment endpoints, webhook handlers, key-handling posture.cicd-devsecops — Vault-managed key rotation and secret distribution.observability-monitoring — PaymentIntent dashboards and webhook lag alerts.docs.stripe.com/paymentsdocs.stripe.com/payments/accept-a-paymentdocs.stripe.com/payments/payment-intentsdocs.stripe.com/api/payment_intents/createdocs.stripe.com/webhooksdocs.stripe.com/api/idempotent_requestsdocs.stripe.com/api/events/typesdocs.stripe.com/currenciesdocs.stripe.com/tax and docs.stripe.com/tax/subscriptionsdocs.stripe.com/billing/customer/tax-idsdocs.stripe.com/testinggithub.com/stripe/stripe-phpgithub.com/stripe/stripe-nodeWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub peterbamuhigire/chwezi-dev-engine --plugin engineering169 skills in this plugin
/accounting-engineUse when designing or implementing double-entry accounting policy and an embedded ledger engine for invoices, payments, stock, balanced postings, mapped accounts, idempotency, reversals, period locks, audit trails, and financial statements./accounting-finance-controllerUse when coordinating accounting and finance implementation reviews, doctrine routing, control evidence, remediation priorities, and release decisions across a software system./advanced-testing-strategyUse when designing or reviewing test strategy for production systems, APIs, mobile apps, SaaS platforms, ERP workflows, and AI-enabled systems. Covers unit, integration, contract, end-to-end, regression, release-gate, and risk-based testing decisions./ai-agent-commercial-operationsUse when pricing, billing, refunding, recognizing revenue, or packaging commercial terms for agentic AI services, or when defining agent SLAs, customer commitments, SLA dashboards, breach credits, and service evidence./ai-agent-compliance-controlsUse when mapping AI agent operations to SOC 2, ISO 27001, HIPAA, audit logs, control testing, attestations, and compliance evidence, including drill-cadence evidence, approval-completeness (PI1.1) gap checks, and signed agent-memory erasure proofs./ai-agent-governance-and-limitsUse when defining agent budgets, step limits, reversibility, blast-radius controls, kill switches, and governance policy for agentic AI systems.Other plugins' skills for the same job