Skip to content

Add fake payments API#45

Open
zergzorg wants to merge 3 commits into
tscircuit:mainfrom
zergzorg:codex/fake-payments-api-1
Open

Add fake payments API#45
zergzorg wants to merge 3 commits into
tscircuit:mainfrom
zergzorg:codex/fake-payments-api-1

Conversation

@zergzorg
Copy link
Copy Markdown

@zergzorg zergzorg commented May 20, 2026

/claim #1

Summary

  • adds an in-memory fake payment model with pending, completed, canceled, and failed lifecycle states
  • adds Winterspec routes for send, list, get, complete, cancel, and fail
  • supports idempotency keys on /payments/send so retried fake payment requests do not create duplicates
  • keeps terminal payments immutable, so completed/canceled/failed fake payments are not mutated by later lifecycle calls
  • documents the fake payment endpoints in the README

Verification

  • bun test tests/routes/payments.test.ts
  • bun test
  • bunx biome check lib/db/schema.ts lib/db/db-client.ts lib/payments/response-schemas.ts routes/payments tests/routes/payments.test.ts README.md
  • bun run build
  • ./node_modules/.bin/tsc --noEmit
  • git diff --check

Follow-up check, 2026-05-23

  • Re-ran bun test tests/routes/payments.test.ts: 5 passed, covering send/list, idempotency replay, get/complete, terminal-state protection, and failed-payment filtering.

Notes

This is intentionally a fake in-memory API only. It does not process real payments, call external payment services, or include any payout/private data.

Signed-off-by: zergzorg <kaluga@me.com>
@zergzorg
Copy link
Copy Markdown
Author

Follow-up after comparing current #1 attempts:

  • Added a failed terminal payment status and POST /payments/fail, giving the fake payment lifecycle pending/completed/canceled/failed states.
  • Covered failed payments through the existing list filter path so callers can inspect failed fake payments by status/repository.
  • Updated README endpoint notes.

Validation:

  • bun test tests/routes/payments.test.ts — passed, 5 tests.
  • bun test — passed, 7 tests.
  • bunx biome check README.md lib/db/schema.ts lib/db/db-client.ts lib/payments/response-schemas.ts routes/payments tests/routes/payments.test.ts — passed.
  • bun run build — passed.
  • ./node_modules/.bin/tsc --noEmit — passed.
  • git diff --check — passed.

Still fake-only: no external payment processor, payout data, or private data is involved.

Signed-off-by: zergzorg <kaluga@me.com>
@zergzorg
Copy link
Copy Markdown
Author

Follow-up after comparing newer same-issue lifecycle attempts:

  • Kept the fallback withDb database process-scoped instead of recreating it whenever route context lacks an injected db.
  • This protects the live/dev payment flow from losing in-memory fake payments between send, list, get, and status-transition requests.
  • Added middleware regression coverage for both fallback-db reuse and preserving an outer test-provided db.

Validation after the push:

  • bun test tests/middleware/with-db.test.ts tests/routes/payments.test.ts
  • bun test
  • bunx biome check lib/middleware/with-db.ts tests/middleware/with-db.test.ts tests/routes/payments.test.ts
  • bunx tsc --noEmit
  • bun run build
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant