Skip to content

Add fake payment API#15

Open
maxrross wants to merge 2 commits into
tscircuit:mainfrom
maxrross:codex/add-fake-payment-api
Open

Add fake payment API#15
maxrross wants to merge 2 commits into
tscircuit:mainfrom
maxrross:codex/add-fake-payment-api

Conversation

@maxrross
Copy link
Copy Markdown

Implements a focused fake payment lifecycle API for the template Winterspec app.

Changes:

  • Add payment schema and persisted in-memory payment records
  • Add send/list/get/complete/cancel/fail payment routes
  • Support retry-safe sends with optional idempotency keys
  • Add route coverage for lifecycle, idempotency, and filtering

Verification:

  • bunx biome check lib/db/schema.ts lib/db/db-client.ts routes/payments tests/routes/payments
  • bun test
  • bun run build
  • git diff --check

/claim #1

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: db4b12b9e2

ℹ️ 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".

}),
})(async (req, ctx) => {
const { payment_id } = await req.json()
const payment = ctx.db.updatePaymentStatus(payment_id, "completed") ?? null
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Share the payment store across requests

In the real Next/Winterspec handler (pages/api/[[...route]].ts), no shared DB middleware is injected, so withDb creates a new in-memory store whenever ctx.db is absent; only tests/fixtures/start-server.ts supplies a process-wide DB. Because this endpoint looks up a payment created by a previous /payments/send HTTP request, production calls to /payments/complete after sending will return null (and /payments/get or /payments/list will similarly see an empty store), making the new payment lifecycle unusable outside the test fixture.

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 ff80a6e. withDb now falls back to a process-wide shared store when production does not inject ctx.db, while tests can still inject isolated DBs. I also added a regression test that sends and completes a payment through a Winterspec bundle without any injected DB middleware, covering the lifecycle path from the review.

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