Skip to content

Add fake payments API#43

Open
firewine wants to merge 2 commits into
tscircuit:mainfrom
firewine:bounty-1-fake-payments-api
Open

Add fake payments API#43
firewine wants to merge 2 commits into
tscircuit:mainfrom
firewine:bounty-1-fake-payments-api

Conversation

@firewine
Copy link
Copy Markdown

Summary

  • add fake payment persistence to the in-memory database
  • add send, list, get, complete, cancel, and fail payment routes
  • document the fake payment lifecycle and cover the main flow in route tests

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.ts
  • npx winterspec bundle -o dist/bundle.js
  • npx tsc --noEmit
  • npx --yes bun test

/claim #1

Copilot AI review requested due to automatic review settings May 20, 2026 06:13
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread routes/payments/list.ts Outdated
Comment on lines +12 to +15
const status = paymentStatusSchema
.nullable()
.catch(null)
.parse(url.searchParams.get("status"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

2 participants