1---2name: skill-stripe-integration3description: Integrate Stripe Checkout, Billing, subscriptions, Customer Portal, invoices, trials, coupons, webhook handling, entitlement sync, and SaaS payment state management.4---56# skill-stripe-integration78## Workflow9101. Inspect existing backend boundaries, env naming, Stripe SDK usage, price/product mapping, subscription tables, and entitlement tables.112. Keep Stripe secret keys and webhook secrets in server-only code. Browser code may only receive publishable keys and backend-created session/portal URLs.123. Create Checkout or Portal sessions on the backend with authenticated actor context and stable metadata.134. Verify webhook signatures with the raw request body before parsing business data.145. Deduplicate events by Stripe event ID and store relevant Stripe IDs for support: customer, checkout session, subscription, invoice, payment intent, price, and product.156. Sync product access from backend subscription/payment state and local entitlement policy, not from the success redirect alone.167. Validate with Stripe test mode, CLI/webhook events, and the project build/typecheck.1718## Guardrails19201. Use official Stripe libraries for webhook signature verification.212. Configure the framework route so the webhook endpoint receives the raw body.223. Listen only to required event types.234. Return a 2xx quickly; move heavy processing to a queue/job when possible.245. Re-fetch critical Stripe objects when event ordering or stale local state matters.256. Keep plan and entitlement rules in local product tables; Stripe prices/products are billing evidence, not the whole access model.267. Never log secret keys, webhook secrets, complete card/payment details, or unnecessary PII.2728## API Versioning2930- Pin the Stripe API version in the server SDK/client or endpoint configuration instead of relying silently on the account default.31- The current Stripe API version at verification time is `2026-02-25.clover`; treat this as a maintenance reference, not a reason to upgrade production automatically.32- Review the Stripe changelog and run a test-mode webhook migration before adopting a new breaking release. Monthly releases within a major release are designed to be backward-compatible, but twice-yearly major releases can require code changes.3334## Typical SaaS Events3536- `checkout.session.completed`: first checkout completion and customer/subscription linking.37- `invoice.paid`: renewal succeeded; extend access.38- `invoice.payment_failed`: mark past due or start grace policy.39- `customer.subscription.updated`: sync status, period, cancellation flags, price changes.40- `customer.subscription.deleted`: revoke or expire access according to policy.4142## Data Contract4344- Map internal plans to Stripe price IDs per environment.45- Store Stripe IDs on server records, not as frontend-only state.46- Track subscription status, current period, cancellation flags, trial dates, grace policy, and last sync timestamp.47- Add audit logs for plan changes, portal cancellations, payment failures, refunds, and admin overrides.4849## Verification5051- Use Stripe test mode and CLI/webhook test events.52- Confirm webhook route is HTTPS in production.53- Confirm live mode uses live price IDs, live keys, and live webhook endpoint secret.54- Check dashboard event deliveries before assuming frontend checkout failed.55- Verify duplicate events do not duplicate payments, extend access twice, or create duplicate audit rows.56- Verify the webhook endpoint's configured API version matches the SDK's event types and deserialization expectations.5758## Official References5960- https://docs.stripe.com/api/versioning61- https://docs.stripe.com/webhooks/versioning62- https://docs.stripe.com/webhooks/signature