本文へ移動
cccskills
無料GitHub で公開

payment-flow-test-author

Build-an-X workflow that authors the full payment-flow test suite in three phases: the refund matrix (full / partial / multiple-partials / over-refund / already-refunded, per-gateway APIs for Stripe, Adyen, PayPal, Braintree), the chargeback / dispute suite (Visa + Mastercard reason codes, evidence submission windows, won / lost / accepted dispositions), and webhook replay + recovery via gateway-native simulators (Stripe CLI trigger / resend, Adyen Customer Area resend, PayPal Webhook Simulator, Braintree sampleNotification). Driven by the state model in payment-flow-states-reference. Use when building refund, dispute, or payment-webhook-robustness coverage for a payment integration; for generic (non-payment) webhook receiver testing use webhook-delivery-tester in the qa-notifications plugin.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qaスター 13(GitHub 13 + cccskills 0)
連携ツールStripe

実行スコア 未検証

インストール方法を見る

含まれるファイル(5)

  • SKILL.md10.7 KB
  • .tessl-plugin/plugin.json943 B
  • references/advanced-recovery-scenarios.md3.1 KB
  • references/reason-codes.md1.5 KB
  • references/replay-simulators.md4.3 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

payment-flow-test-author

Overview

The three highest-incident payment surfaces after the happy path - refunds, disputes, and webhook handling - are one suite-authoring job, because they share the same substrate: the gateway's async state machine. This workflow builds all three phases in dependency order, driven by the canonical states in payment-flow-states-reference.

Common bugs each phase catches: double-refund and partial-refund-not-summing (Phase 1); missed evidence deadlines and unreconciled chargeback fees (Phase 2); non-idempotent redelivery handling and spoofable handlers (Phase 3).

When to use

  • New payment integration; need refund / dispute / webhook coverage.
  • A refund- or webhook-related incident; need to backfill tests.
  • Gateway migration; need to re-validate flow logic.

Phase 0 - Map the state machine

Before writing any test, translate the canonical lifecycle (created → requires_action → processing → succeeded → refunded / disputed) into your gateway's vocabulary using payment-flow-states-reference. Every assertion below is on a state from that grid, and every async assertion waits on the webhook, never the synchronous API return.

Phase 1 - The refund matrix

Inventory refund touchpoints

grep -rn 'refund\|Refund\|REFUND' --include='*.{ts,js,py,java,go,rb,cs}' .

Categorise per gateway + per code path (order cancellation, CS portal, subscription downgrade, dispute-lost automation).

The 7 canonical refund cases

For each (gateway, touchpoint):

#TestExpected
1Full refund of captured chargerefund.status = succeeded; charge.amount_refunded = charge.amount
2Partial refund (50%)refund.amount = 0.5x charge.amount
3Multiple partials summing to fullCumulative refunded = charge.amount; charge.refunded = true
4Over-refund attempt (101%)Gateway rejects; descriptive error
5Refund of already-fully-refunded chargeRejected with "charge_already_refunded" or equivalent
6Refund of failed chargeRejected; no refund created
7Refund of disputed chargePer gateway policy: blocks or allows without reversing the dispute

Per-gateway refund APIs

Stripe, per docs.stripe.com/refunds:

test('over-refund rejected', async () => {
  const intent = await createSucceededIntent({ amount: 1000 });
  await expect(
    stripe.refunds.create({ payment_intent: intent.id, amount: 1500 })
  ).rejects.toThrow(/refund_amount_exceeds_charge_amount/);
});

Adyen refunds are async, per docs.adyen.com/online-payments/refund: the call returns [refund-received]; completion arrives as a [REFUND] notification - assert via webhook, not the sync response. PayPal uses CapturesRefundRequest per developer.paypal.com/docs/api/payments/v2#captures_refund; Braintree requires settlement first (gateway.testing.settle, sandbox-only) before gateway.transaction.refund.

Refund idempotency

test('idempotent refund', async () => {
  const intent = await createSucceededIntent({ amount: 1000 });
  const key = 'refund-' + intent.id;
  const r1 = await stripe.refunds.create({ payment_intent: intent.id, amount: 500 }, { idempotencyKey: key });
  const r2 = await stripe.refunds.create({ payment_intent: intent.id, amount: 500 }, { idempotencyKey: key });
  expect(r1.id).toBe(r2.id);
});

Without idempotency, network retries double-refund the customer.

Phase 2 - The chargeback / dispute suite

  1. Pick the 3-5 reason codes most common for your business from references/reason-codes.md - each code has different evidence requirements.
  2. Trigger a disputable charge in the gateway's test mode (Stripe pm_card_createDispute per docs.stripe.com/testing#disputes; an Adyen [CHARGEBACK] notification per docs.adyen.com/risk-management/disputes-api; a PayPal sandbox dispute per developer.paypal.com/docs/api/customer-disputes/v1).
  3. Assert the dispute lands in needs_response (or the gateway equivalent) with the expected reason.
  4. Submit evidence before evidence_details.due_by and assert has_evidence is set, per docs.stripe.com/disputes/responding.
  5. Drive each disposition - won (winning evidence), lost (no response), accepted - and confirm the final state via the charge.dispute.closed webhook.
  6. Verify the ledger reverses funds plus the chargeback fee on a lost dispute.
test('lost dispute reverses funds in ledger', async () => {
  const intent = await createSucceededIntent({ amount: 1000 });
  const dispute = await triggerLostDispute(intent);
  await waitForChargebackEvent();

  const ledger = await getLedgerEntries(intent.id);
  expect(ledger).toContainEqual(expect.objectContaining({ type: 'chargeback', amount: -1000 }));
  expect(ledger).toContainEqual(expect.objectContaining({ type: 'chargeback_fee' }));
});

Phase 3 - Webhook replay via gateway-native simulators

Payment webhooks are the source of truth for async transitions, so every handler must be signature-verified, idempotent, order-tolerant, and replay-safe.

  1. Confirm the handler reads the raw request body - signature verification fails on parsed-then-restringified bytes.
  2. Run the four-case signature gauntlet (unsigned / wrong-secret / valid / expired-timestamp) for your gateway; the per-gateway signature schemes, simulator commands, and the full gauntlet code are in references/replay-simulators.md.
  3. Add the idempotency dedup test - redelivery must not double-process:
test('redelivered webhook handled idempotently', async () => {
  const payload = makeWebhookPayload({ type: 'payment_intent.succeeded' });
  const sig = signPayload(payload);

  await postWebhook(payload, sig);
  await postWebhook(payload, sig);  // redelivery

  const rows = await db.payment_records.count({ event_id: payload.id });
  expect(rows).toBe(1);             // processed exactly once
});
  1. Wire the gateway's replay simulator and drive a real event end to end:
stripe trigger payment_intent.succeeded    # synthetic event to the forward URL
stripe events resend evt_test_12345        # replay a captured event (30-day window)
  1. Add the harder recovery scenarios - out-of-order delivery, mid-handler crash, archive replay, per-gateway suite layout - from references/advanced-recovery-scenarios.md.

For generic webhook receiver testing (Standard-Webhooks signature scheme, non-payment senders, inbound replay hardening), use webhook-delivery-tester in the qa-notifications plugin; this phase covers the payment-gateway-specific surface only.

Emit the coverage matrix

# tests/payment/flow-matrix.yaml
matrix:
  gateways: [stripe, adyen, paypal, braintree]
  refund_variants: [full, partial, multiple-partials, over-refund, already-refunded, failed-charge, disputed-charge]
  dispute_cells: ["Visa 10.4", "Visa 13.1", "Mastercard 4855"] # x [won, lost, accepted]
  webhook_cases: [signature-gauntlet, idempotent-redelivery, out-of-order, crash-recovery]

Report the matrix per release and document deliberate gaps.

Anti-patterns

Anti-patternWhy it failsFix
Test only full-refund happy pathPartial-refund accounting bugs hidePer-variant test
No idempotency key on mutating callsNetwork retry → double refund / chargeAlways set
Skip dispute testsWorst-case impact is highCover top 3-5 reason codes
No due-date trackingEvidence submitted late → auto-loseTest the due-date watcher
Skip chargeback-fee reconciliationBooks don't matchTest the ledger
Skip signature verificationSpoofed webhook payloadsFour-case gauntlet per gateway
Trust HTTP 200 == processedServer may have crashed mid-handlerAtomic commit + event-ID record
Sync assertions on async flowsAdyen / PayPal finalize via webhookWebhook-driven asserts per Phase 0
Test against live APIsReal moneySandbox-only, per payment-gateway-sandboxes

Limitations

  • Real chargebacks take weeks. Test mode collapses the timeline; production verification needs production traffic.
  • Reason codes change. Visa / Mastercard publish updates; test data goes stale annually.
  • Bank-declined refunds simulate poorly; rely on platform-documented test cases.
  • Bank-initiated webhooks aren't always test-mode-triggerable.

References

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

Builds a CI gate that fails the build on **new** WCAG / a11y violations introduced by a PR while grandfathering pre-existing violations on a per-rule / per-page baseline. Aggregates verdicts from axe-core / pa11y / Lighthouse a11y / WAVE / IBM Equal Access scans. Use when a project has accumulated a11y debt and a strict "zero violations" gate would block every PR - the ratchet pattern lets the team ship while preventing regressions.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

Workflow skill that builds an A/B-test validity checklist from an experiment proposal, walking the canonical design-correctness gates - pre-registered OEC/power/guardrails, randomization unit + SRM check, assignment integrity, telemetry, peeking discipline, novelty/primacy, post-experiment SRM re-check - into a per-experiment checklist + sign-off form. Use when launching, auditing, or governing an experiment. For pitfall mechanics (guardrails, peeking) see experiment-results-interpreter's references; to read an already-valid result use experiment-results-interpreter; for per-SDK harness tests use experiment-sdk-testing - this gates DESIGN, not SDK code.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

The single install-flow skill: the reference contract for the PWA install flow (installability gate fields, `beforeinstallprompt` handshake, per-platform paths - Android WebAPK / iOS Share menu / Firefox no-op - and the `display-mode` post-install signal, in references/install-flow-reference.md) plus the build-an-X workflow that emits the Add-to-Home-Screen suite. Walks the four-stage timeline, emitting one test per gate cell per [web.dev/articles/install-criteria][install-criteria], the deferred-prompt → `prompt()` → `userChoice` chain per [web.dev/articles/customize-install][customize-install], the iOS Safari manual-metadata branch (`apple-touch-icon`) per [web.dev/learn/pwa/installation][learn-pwa], and the post-install `(display-mode: standalone)` MQ assertion. Output: a Playwright spec with per-stage cells plus a coverage matrix. Use when a PWA's manifest, icons, or install handler change, when install conversion drops at an unknown stage, or when triaging a flaky install assertion.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

Build-an-X workflow that uses an LLM to map existing tests to spec sections - given a spec doc + the test suite, the LLM identifies which tests cover which sections, surfaces uncovered sections (gap), and recommends specific tests to add. Output is a coverage matrix per spec ID. Scope is mapping tests that already exist and naming the gaps, not authoring tests for new acceptance criteria. Use when a spec doc and a test suite both exist but nobody can say which requirements are actually covered - before a release sign-off, an audit, or a decision about where to spend the next round of test effort.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

Generates tests from natural-language specs (acceptance criteria, user stories, requirements) using an LLM, with confidence scoring per test case (LLM self-assessment plus heuristics: assertion quality, naming, completeness), batching uncertain cases for human review, and integration with the team's existing test framework. Use when the user asks to generate unit tests from acceptance criteria, convert user stories to test cases, automate test creation from requirements, or augment a spec-driven test suite with AI-generated stubs that are then curated before merge.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

Configures Allure Report (test-runner adapter install, `allure-results` directory wiring, `categories.json` for failure classification, `history-trend.json` retention via the copy-history-between-runs pattern), runs the Allure CLI to convert `allure-results` to a static HTML site, and uploads the report as a CI artifact. Use when the team needs richer test reporting than JUnit XML - step-level attachments, per-test history, retry tracking, and severity / epic / feature labeling across framework-agnostic adapters (pytest, Jest, JUnit, TestNG, NUnit, Mocha). As a rich static HTML report generator, it is the open-source alternative to the sunset ExtentReports (JVM/.NET per-test HTML narrative); for hosted cross-run flakiness analytics rather than a static per-run report use currents-integration.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

testland のスキルをすべて見る

このスキルの問題を報告する