agentleFS
CaduS0uzaCaduS0uza/qa-supreme/skills/payment-testing/SKILL.md

payment-testing

Skill1 starsChanged 2 months agoMITView on GitHub

Test checkout, charges, refunds and subscriptions without ever creating a real charge — provider sandboxes, the decline matrix, webhook idempotency, and the money invariants that must never break. Use when the change touches payment, billing, pricing, refunds, plans, or anything that moves an amount.

  • Reads credentials

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Every other defect costs trust.

    line 8
  2. Distinctive:

    Test the failures, not the happy path — the happy path is the one everyone already checked:

    line 23
  3. Distinctive:

    One payment, one charge: No path — retry, double-click, refresh, back button, duplicate webhook — produces two charges.

    line 42
  4. Very specific:

    State machine is closed: Use state-machine-testing: pending → paid → refunded, and every invalid transition refused (approving a cancelled …

    line 50

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Payment Testing

Every other defect costs trust. This one costs money, twice: once to the customer and once to whoever refunds it. Payment code is P0 by definition — risk-map never has to think about it.

Never test against live keys

sk_live_* in a test environment is an incident waiting for a CI run. Use the provider sandbox (Stripe test mode, PagSeguro sandbox, Mercado Pago test users), seeded per environment, and make the suite fail loudly if a live key is ever present:

expect(process.env.STRIPE_KEY, 'live key in a test run').toMatch(/^sk_test_/)

The decline matrix

Test the failures, not the happy path — the happy path is the one everyone already checked:

CaseProvider test cardThe product must
Approved4242 4242 4242 4242create exactly one charge and one order
Generic decline4000 0000 0000 0002show why, keep the cart, allow retry
Insufficient funds4000 0000 0000 9995distinguish from a generic decline
Expired card4000 0000 0000 0069ask for a new card, not "try again later"
Wrong CVC4000 0000 0000 0127flag the field, not the whole form
Requires 3DS4000 0025 0000 3155complete the challenge, and handle abandoning it
Fraud block4100 0000 0000 0019fail closed, never create the order

The abandoned-3DS path is the classic silent bug: the customer closes the challenge window and the product is left holding a pending order it never resolves.

Money invariants (assert these, always)

  • Integer cents, never floats. 0.1 + 0.2 !== 0.3 is a rounding bug with a refund attached. Assert the stored type as well as the value.
  • One payment, one charge. No path — retry, double-click, refresh, back button, duplicate webhook — produces two charges. Test the double-click explicitly; users double-click.
  • Total = sum of parts. Items + shipping + tax − discount, asserted end to end, with a discount larger than the subtotal (must clamp to zero, never negative).
  • Currency is never assumed. Amount and currency travel together; a BRL amount displayed as USD is a 5× error.
  • Refund ≤ captured, partial refunds sum to no more than the charge, and a refunded order cannot be refunded again.
  • State machine is closed. Use state-machine-testing: pending → paid → refunded, and every invalid transition refused (approving a cancelled order, capturing twice).

Webhooks are the real risk

Providers retry. Networks duplicate. Order of delivery is not guaranteed.

  • Same event id twice → one effect. This is the single most valuable payment test you can write.
  • Signature verification: valid, tampered body, replayed timestamp, wrong secret → rejected.
  • Out-of-order: payment_succeeded arriving before checkout_completed.
  • Unknown event type → 200 and ignored, never a 500 that makes the provider retry forever.
  • The idempotency key is written in the same transaction as the effect, not after it.

Reconciliation

The strongest test in the whole area: after a batch of simulated activity, the sum of charges in your database equals the sum in the provider's. Run it nightly against sandbox data. It catches the class of bug no unit test sees — the one where your record and the money disagree.

Done means

The decline matrix run with output pasted, the duplicate-webhook test proven with mutation-proof, and an explicit line saying no live key was in scope.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.