Instructions
Plan payments integration with strict PCI boundaries and Next.js. Read payments-pci.md before proposing checkout or webhook fulfillment.
When to Use
- Use when designing checkout, PaymentIntents, refunds, or order fulfillment from payment events.
- Prefer
webhook-receiversfor signature verify + idempotency handler details. - Prefer
api-handbookfor idempotent order APIs that webhooks call. - Prefer
env-config-agentwhen live vs test keys or secret leakage is the issue.
- Never store PAN, CVV, or mag stripe data. Use PSP-hosted fields (card Element / Payment Element) so card data touches PSP JS only.
- Server: create PaymentIntent / session server-side with idempotency key; return client secret to UI; verify amounts and currency server-side on success.
- Webhooks: implement with
webhook-receivers- verify signature, idempotent event processing, handle capture vs metadata order (see payments-pci.md). - PCI scope: prefer SAQ A-style architecture (redirect or iframe/Element hosted by PSP); documenting “we never touch raw card” is required in reviews.
- Refunds / disputes: outline state machine (pending → succeeded → refunded); no destructive scripts without approval.
- Testing: PSP test cards only; no live keys in repo;
.env.examplekey names only. - Fulfillment: pair with
api-handbookfor idempotent order creation from webhook handlers. - Logging red lines: never log
client_secret, PAN, or full unredacted webhook bodies.
Outcomes
- Architecture diagram (bullet): browser → PSP → your API → DB + webhooks.
- Checklist: idempotency, amount verification, logging red lines.
Output Rules
read-only design unless the user explicitly requests code and approves. No real API keys.
Scope and boundaries
- In scope: integration patterns, PCI boundaries, webhook pairing.
- Out of scope: tax/VAT legal advice, crypto on-ramp compliance, custom acquirer protocols.
Safety
- high + requires_user_approval: true - money and compliance.
- Do not suggest storing cardholder name + PAN together in your DB.
Troubleshooting
- Webhook amount mismatch: always fetch authoritative intent from PSP API before fulfilling.
- Client secret leaked: rotate keys; never log
client_secret. - Double charge risk: missing idempotency key on intent creation - add before retry logic.
Related skills
webhook-receivers- signed, idempotent handlersapi-handbook- order APIsenv-config-agent- key hygiene
GitHub: https://github.com/bh611627/skillcodex/tree/main/skills/payments-handbook/SKILL.md
npm: https://www.npmjs.com/package/@skillcodex/skills