agentsclimarketplace

Audit payment system

Skill kensaurus/cursor-kenji/skills/audit-payment-system

πŸ¦–Curated Cursor AI agent skills, slash commands, MCP configs, subagents & rules for full-stack dev β€” React 19, Next.js 15, Supabase, Tailwind v4, TypeScript

Install
npx -y skills add kensaurus/cursor-kenji --skill audit-payment-system

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 6 stars6 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Read-only audit for payment/money-movement systems, scope-gated so a simple Stripe-Checkout site and an in-house ledger/gateway each see only relevant findings. Checks the things that lose money or trigger PCI liability: idempotency on every mutation (double-charge on retry), double-entry append-only ledger, payment state machine (no double-capture), sync-auth vs async-webhook flow, HMAC + event-id webhook dedup, 3-way reconciliation vs PSP settlement, fraud/velocity + 3DS/SCA, multi-currency in minor units, PCI DSS v4.0.1 (never log PAN, tokens only, key rotation), and resilience (PSP timeout, partial ledger write, breaker). Uses the Stripe MCP for version-anchored provider checks when the PSP is Stripe. Use when "audit payment system", "payment gateway audit", "double charge / idempotency", "ledger / reconciliation", "webhook / 3DS / PCI", or "audit-payment-system". Defers per-call resilience to audit-resilience, PCI/secrets to audit-security, ledger schema to audit-db-schema.

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

18.8 KB, as published. Nobody here has run it

audit-payment-system β€” Money-Movement Correctness & Compliance Audit

Payment code fails differently from normal CRUD. A dropped PUT is an annoyance; a retried charge is a double-charge, a lost ledger write is money that vanished, a logged PAN is PCI liability, and an unverified webhook is a spoofed "payment succeeded". The bugs are silent β€” everything looks green until a customer is charged twice or the month-end books don't balance. This audit checks the controls that keep every cent accounted for and every charge exactly-once.

The 2026 consensus is consistent across sources: a payment system rests on three pillars β€” idempotency, a double-entry ledger, and reconciliation β€” with PCI DSS v4.0.1 as a non-negotiable floor and webhooks as the source of truth (never trust the synchronous API response alone).

Read-only. This skill assesses and prioritizes; it does not change code. Payment code is a STOP-and-confirm surface (see the composer execution rule) β€” findings here feed a human-reviewed remediation, ideally with a stronger model, not an unattended edit. Delegations: per-call runtime resilience β†’ audit-resilience; PCI/secrets/authz/injection β†’ audit-security; ledger & partitioning schema β†’ audit-db-schema; outbox/saga structure β†’ audit-backend-architecture; destructive/append-only integrity β†’ plan-data-integrity; Stripe-specific integration β†’ the Stripe plugin skills. This skill owns the payment-domain correctness layer and links out rather than duplicating.


Core principle β€” earn each control by scope; every gap is money or liability

Not every app needs an in-house double-entry ledger. A shop using Stripe Checkout offloads the ledger, settlement, and most PCI scope to Stripe β€” flagging "no double-entry ledger" there is noise. But idempotency, webhook verification, state sync, and tokens-only apply to everyone who moves money. Gate depth by scope (Phase 0), then treat every in-scope gap by its blast radius: Critical = a customer is charged twice, money is lost/unaccounted, or card data is exposed. There is no "low severity" for a double-charge.


Phase 0 β€” Detect payment surfaces & scope (gates every later finding)

Find the money paths and the provider first; the scope tier decides which controls are in play. Never report an in-house-ledger control as "Missing" on a pure merchant-integrator (N/A with a reason).

# Provider / SDK
rg -n --hidden -g '!node_modules' -i "stripe|paypal|braintree|adyen|square|payjp|paypay|razorpay|checkout\.com|worldpay|mollie|@stripe/|payment_intent|paymentintent" -l
# Money-movement verbs
rg -n -i "\b(charge|capture|authoriz|refund|void|payout|settle|chargeback|dispute|reversal)\b" -l
# Webhook endpoints + signature
rg -n -i "webhook|/webhooks?|constructEvent|verifyHeader|Stripe-Signature|x-signature|hmac" -l
# Idempotency
rg -n -i "idempotenc|idempotency[-_]?key|Idempotency-Key" -l
# Ledger / accounting
rg -n -i "ledger|double[-_ ]entry|debit|credit|journal|balance|posting|book(keeping)?" -l
# Reconciliation / settlement
rg -n -i "reconcil|settlement|settle|payout report|balance_transaction|three[-_ ]way" -l
# Money type (float smell = red flag)
rg -n -i "amount|price|money|currency|minor[-_ ]unit|cents" -g '*.{ts,tsx,js,py,go,java,rb,cs,sql}' -l
# Fraud / risk / SCA
rg -n -i "fraud|risk|velocity|3ds|3-?d ?secure|sca|radar|device.?fingerprint" -l
# Card-data smell (should find NOTHING raw)
rg -n -i "card[-_ ]?number|\bpan\b|cvv|cvc|card\.number|primary_account" -l

Record a payment profile and pick the tier β€” apply only in-scope rows:

TierSignalsIn scope
P0 β€” Merchant integratoruses hosted Checkout / PaymentIntents / a PSP SDK; PSP holds the money & ledgerIdempotency on mutations, webhook verify+dedup, payment-state sync (pull-based recovery), refund/void idempotency, tokens-only/PCI-SAQ scope, light recon vs PSP dashboard, resilience around PSP calls
P1 — Platform / marketplaceConnect-style split payments, payouts to sellers, multi-party balances+ payout/clawback saga, an internal ledger for balances owed, multi-party reconciliation, dispute→clawback flow
P2 β€” Gateway / PSP / wallet / fintechown ledger, direct acquirer/bank/card-network, issues balances+ full double-entry append-only ledger, 3-way reconciliation (ledger↔settlement↔bank), settlement-file ingestion, sharding/serialized balance updates, in-house fraud engine, AML/sanctions, PCI DSS Level 1

If there is no money movement (no PSP, no charge/ledger paths), stop and report reduced applicability. If card data appears in the last rg above, that is Critical, report immediately.


Phase 1 β€” Research (version-anchored, provider-aware)

Follow /research. Anchor to the installed SDK version and the provider's current API (e.g. Stripe PaymentIntents, not the legacy Charges API, which lacks native SCA/3DS2). Confirm the current-year shape of the controls before judging the code.

When the provider is Stripe, use the Stripe MCP as the authoritative source:

  • Concepts / best practice (idempotency keys, webhook signature verification, PaymentIntents lifecycle, SCA/3DS2, Radar) β€” search_stripe_documentation with search_only_api_ref: false, e.g. { "question": "verify webhook signatures and prevent duplicate event processing", "language": "node" }.
  • Exact API params the integration should be sending β€” stripe_api_search (intent + resource) then stripe_api_details on the operation id (e.g. confirm PaymentIntent.create is called with an idempotency key and amounts in minor units).

For PayPal / Square / Adyen / PayPay / Braintree / others, the Stripe MCP does not apply β€” use /research against the provider's official docs (idempotency header, webhook/HMAC verification, 3DS/SCA, settlement report format). Never invent a param or endpoint the provider doesn't expose.


Phase 2 β€” Payment correctness matrix

For each in-scope row, mark Implemented / Partial / Missing / N/A with file:line, a one-line "why it bites in prod", and the fix-delegate. Full detection commands, good-vs-red-flag signals, and fix targets are in references/checklist.md β€” load it and work the applicable groups.

A. Money-movement correctness (P0+)

#ControlBites in prod if missingFix via
A1Idempotency on every mutation (charge/capture/refund/void) β€” key from business intent, enforced at gateway and a DB unique constraintNetwork retry β†’ double charge; the DB constraint is the last line of defenseaudit-resilience, backend-patterns
A2Dedup / stored result β€” reused key returns the prior result; reused key + different payload is rejectedRetry runs the charge twice; or a bug reuses a key for a new amountaudit-resilience
A3Payment state machine — explicit permitted/prohibited transitions; capture-twice is idempotent (2nd returns success, no re-process); no SETTLED→AUTHORIZED, no re-capture of REFUNDEDDouble-capture, refund-after-refund, stuck-in-limbo paymentsbackend-patterns
A4Money as integer minor units (never float); currency travels with amountFloat rounding silently loses/creates fractions of a cent at scaleaudit-db-schema
A5Multi-currency & FX β€” no cross-currency arithmetic; FX rate captured at posting time; explicit rounding (e.g. bankers')Mixed-currency sums, rounding drift, unreproducible historical amountsbackend-patterns

B. Ledger & data integrity (P1 internal balances Β· P2 full ledger)

#ControlBites in prod if missingFix via
B1Double-entry β€” every movement writes balanced debit+credit; sum of all entries = 0 (the invariant that proves nothing leaked)Money "vanishes" or is created; books never balance; undetectable until auditaudit-db-schema, backend-patterns
B2Append-only / immutable transaction & ledger tables β€” corrections are reversing entries, never UPDATE/DELETEAn edited/deleted row destroys the audit trail; disputes become unwinnableplan-data-integrity, audit-db-schema
B3Balance = derived, snapshotted separately β€” current balance is a snapshot/materialization of ledger entries, not a hand-updated columnBalance column drifts from the ledger; two sources of "truth"audit-db-schema
B4Auditability β€” event-sourced/immutable history reconstructs any transaction; every access to txn data is loggedCan't answer "what happened to charge X"; fails compliance auditbackend-observability, audit-security
B5Schema for scale β€” partition by date (manageable rows/day), indexed for recon queriesUnbounded hot table; recon and reporting time outaudit-db-schema

C. Async orchestration & webhook delivery (P0+)

#ControlBites in prod if missingFix via
C1Sync-auth vs async-everything β€” authorization is synchronous; settlement, webhooks, reporting, recon are asyncSlow downstream blocks the checkout; or status trusted from a response that liedaudit-backend-architecture
C2Webhook signature verified (HMAC / provider constructEvent) before any processingSpoofed "payment succeeded" β†’ goods shipped for freeaudit-security
C3Webhook event-id dedup + 200-then-process β€” record processed event ids; ack 200 immediately, process asyncPSP retries for days β†’ the same event processed twice (double ledger post)audit-resilience
C4Atomic state+ledger+outbox β€” the state transition, ledger posting, and outbound event commit in one DB transaction (outbox relay publishes)Dual-write: crash mid-way = captured payment with no fulfillment event, or vice versaaudit-backend-architecture, backend-patterns
C5Pull-based recovery for stuck payments β€” a worker scans transitional states past a timeout and queries the PSP as source of truthA lost webhook leaves a payment stuck forever; user re-tries β†’ double chargebackend-patterns
C6Refund/dispute/payout as saga β€” multi-service steps with compensations (reverse auth, negative ledger entry, payout clawback, notify)A half-done refund claws back money but never notifies, or refunds twicebackend-patterns

D. Reconciliation & settlement (P1/P2)

#ControlBites in prod if missingFix via
D1Automated daily reconciliation vs the PSP settlement file β€” the single most important controlLedger and PSP silently diverge (timing, lost webhooks); discrepancies compoundbackend-patterns, data-pipeline
D23-way match (internal ledger ↔ card-network/PSP ↔ bank statement) with a break reportMissing/extra/mismatched txns go unnoticed; revenue leakage & fraud hiddendata-pipeline
D3Discrepancy handling β€” missing txn escalated; extra bank txn found-or-reversed; amount mismatch checks FX; rounding-only auto-resolvedEvery break needs a human; or breaks silently ignoredbackend-patterns
D4Safety brake β€” unreconciled balance over a threshold halts new captures / alertsLosses accumulate faster than they're caughtaudit-resilience

E. Fraud, risk & SCA (P0 delegate Β· P1/P2 in-house)

#ControlBites in prod if missingFix via
E1Risk scoring pre-auth β€” velocity, geolocation, amount, device fingerprint via rules engine (+ ML score where present)Card-testing / stolen-card attacks; chargebacksbackend-patterns
E23DS2 / SCA step-up β€” high-risk/PSD2-region β†’ 3D Secure challenge; low-risk β†’ frictionless via exemptionsNon-compliant in EU (declines) or friction everywhere (lost conversion)provider docs / backend-patterns
E3Fraud-service failure policy β€” explicit fail-open vs fail-closed when the risk service is down (breaker)Fraud service down β†’ either block all revenue or wave through all fraudaudit-resilience
E4Chargeback / dispute monitoring β€” track ratio, react before acquirer watchlist (VAMP/VDMP) thresholdsProgram placement / fines; account terminationbackend-observability
E5AML / sanctions screening (P2 / regulated)Regulatory exposure for regulated flows/research + human

F. Compliance & security β€” PCI DSS v4.0.1 (all tiers)

#ControlBites in prod if missingFix via
F1Never store/log PAN or CVV β€” tokens only; card data never touches your servers/logs (scope reduction)PCI breach liability; CVV storage is flatly prohibitedaudit-security
F2Tokenization β€” hosted fields / PaymentIntents so raw card data bypasses your infraBalloons PCI scope from SAQ-A to full auditprovider docs
F3Key rotation & secret handling β€” API/signing keys rotated, never in code/logsLeaked long-lived key = unlimited charges/refundsaudit-security, plan-secrets-audit
F4Access audit β€” every read/write of transaction/PII data is logged & attributableCan't prove who touched payment data; fails auditaudit-security, backend-observability

G. Error handling & resilience (P0+)

#ControlBites in prod if missingFix via
G1PSP/bank API timeout + retry with backoff and a circuit breakerOne slow provider exhausts the pool β†’ whole checkout 503saudit-resilience
G2Bulkhead / pool isolation β€” PSP calls can't starve the DB/other depsTimeout storm cascades across the systemaudit-backend-architecture
G3Partial-write safety β€” state + ledger commit atomically; no "charged but not booked"Money taken, ledger never posted (or reverse)backend-patterns
G4Graceful degradation for non-critical deps (fraud/notification down β‰  block auth, per policy)A non-critical outage takes payments offlineaudit-resilience

Rules:

  • Evidence or it didn't happen β€” every verdict cites file:line or "searched, none found".
  • N/A is first-class β€” record why (scope tier), don't drop the row.
  • No double-counting β€” link per-call resilience to audit-resilience, PCI to audit-security.

Phase 3 β€” Prioritized report (read-only)

## Payment System Audit β€” [repo] β€” [date]
**Provider(s):** [Stripe/PayPal/…]  Β·  **Scope tier:** [P0/P1/P2 + evidence]
**In scope:** [groups]  Β·  **N/A (out of tier):** [rows + why]

### Critical β€” money loss / double-charge / card-data exposure (fix before ship)
| Finding | Control | file:line | Why it bites | Fix via |
|---|---|---|---|---|
| Charge has no idempotency key; no unique constraint | A1 | pay/charge.ts:52 | Retry double-charges the customer | audit-resilience |
| Webhook processed without signature check | C2 | api/webhook.ts:9 | Spoofed "paid" β†’ free goods | audit-security |
| Card number written to app log | F1 | pay/log.ts:20 | PCI breach liability | audit-security |
| DB write then broker publish (not atomic) | C4 | ledger.ts:88 | Captured, never booked β†’ money unaccounted | backend-patterns |

### High / Medium (correctness & compliance matrix)
| Group | Implemented | Partial | Missing | N/A | Fix via |
|---|---|---|---|---|---|
| A Money-movement | … | … | … | | audit-resilience |
| B Ledger | … | … | … | (P0) | audit-db-schema |
| C Webhooks/async | … | … | … | | backend-patterns |
| D Reconciliation | … | … | … | (P0) | data-pipeline |
| E Fraud/SCA | … | … | … | | backend-patterns |
| F PCI/compliance | … | … | … | | audit-security |
| G Resilience | … | … | … | | audit-resilience |

### Lift-to-production roadmap (ordered by blast radius)
1. Idempotency (gateway + DB unique constraint) on every mutation β†’ audit-resilience
2. Verify + dedup webhooks, 200-then-process async β†’ audit-security / audit-resilience
3. Atomic state+ledger+outbox; pull-based recovery for stuck payments β†’ backend-patterns
4. [P1/P2] Double-entry append-only ledger + daily reconciliation w/ break report β†’ audit-db-schema / data-pipeline
5. Tokens-only + key rotation + access audit (PCI v4.0.1) β†’ audit-security
6. Breaker/bulkhead + fraud fail-policy around every external call β†’ audit-resilience

Forbidden: declaring "production-grade" from passing tests alone; flagging P2-only controls (in-house ledger, 3-way bank match, sharding) against a P0 merchant integrator; re-auditing per-call timeouts/retries audit-resilience owns; assigning any severity below Critical to a double-charge, lost-money, or PAN-exposure finding; recommending a refund/payout saga without compensation logic; editing payment code β€” this skill reports; remediation is human-reviewed (route to a stronger model per the composer execution rule).


Related

  • audit-resilience β€” per-call idempotency keys, timeouts, retry+backoff+jitter, circuit breaker, cancellation
  • audit-security β€” PCI/PAN handling, webhook auth, secrets, key rotation, injection, access logging
  • audit-db-schema β€” double-entry ledger schema, append-only constraints, money types, partitioning
  • audit-backend-architecture β€” outbox/saga/breaker structure and topology fit (this skill checks payment correctness on top)
  • plan-data-integrity β€” append-only/immutability guarantees and destructive-op safety
  • plan-secrets-audit β€” rotate vs relocate provider API/signing keys
  • backend-patterns / backend-patterns/references/architecture-patterns.md β€” implement idempotency, outbox, saga, state machine
  • data-pipeline β€” reconciliation/settlement ingestion jobs
  • the Stripe plugin skills (stripe-best-practices, connect-recommend, upgrade-stripe) β€” Stripe-specific integration
  • complete-everything β€” close audited gaps to done with verification (human-reviewed for payment code)

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.