Add fake payments API#43
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ea940ae351
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const status = paymentStatusSchema | ||
| .nullable() | ||
| .catch(null) | ||
| .parse(url.searchParams.get("status")) |
There was a problem hiding this comment.
Reject unknown payment status values in list filter
Using paymentStatusSchema.nullable().catch(null) turns any invalid status query value into null, so requests like GET /payments/list?status=complete silently drop the filter and return all payments instead of surfacing input error. This can mislead callers and break workflows that depend on strict filtering; invalid enum values should be rejected (e.g., 400) rather than treated as “no filter.”
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in e5a39dc by validating status with safeParse and returning 400 for unknown values. I also added a regression test for /payments/list?status=complete.
There was a problem hiding this comment.
Pull request overview
Adds a fake, in-memory Payments API (backed by the existing Zustand-based DB) to support local demos/tests without integrating a real payment provider, addressing Issue #1’s “send payment” API bootstrap.
Changes:
- Extended the in-memory database schema/client to persist payments and support status transitions with terminal-state protection.
- Added payment lifecycle routes: send, list, get, complete, cancel, and fail.
- Documented the fake payment lifecycle in the README and added an end-to-end route test covering the main flow (including idempotent send and terminal-state behavior).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
lib/db/schema.ts |
Adds Payment/PaymentStatus schemas and stores payments in the database state. |
lib/db/db-client.ts |
Implements payment persistence + lifecycle operations (sendPayment, listPayments, getPayment, updatePaymentStatus). |
lib/payments/schemas.ts |
Introduces request/response Zod schemas for the payments routes and amount normalization helper. |
routes/payments/send.ts |
Implements payment creation endpoint (including idempotency handling via DB client). |
routes/payments/list.ts |
Implements payment listing with optional recipient/status filters. |
routes/payments/get.ts |
Implements payment retrieval by payment_id. |
routes/payments/complete.ts |
Implements transition to completed. |
routes/payments/cancel.ts |
Implements transition to canceled. |
routes/payments/fail.ts |
Implements transition to failed. |
tests/routes/payments.test.ts |
Adds an integration test covering send/list/get/complete and terminal-state immutability. |
README.md |
Documents the fake payments API and lifecycle behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Validation
npx biome check README.md lib/db/db-client.ts lib/db/schema.ts lib/payments/schemas.ts routes/payments tests/routes/payments.test.tsnpx winterspec bundle -o dist/bundle.jsnpx tsc --noEmitnpx --yes bun test/claim #1