Skip to content

Add fake payment lifecycle API#25

Open
tarunag10 wants to merge 1 commit into
tscircuit:mainfrom
tarunag10:codex-payment-api-bounty
Open

Add fake payment lifecycle API#25
tarunag10 wants to merge 1 commit into
tscircuit:mainfrom
tarunag10:codex-payment-api-bounty

Conversation

@tarunag10
Copy link
Copy Markdown

Summary

  • add in-memory fake payment records with send/list/get/complete/cancel lifecycle routes
  • support retry-safe sends with either an idempotency_key body field or Idempotency-Key header
  • preserve default middleware payment state across requests with a shared in-memory DB
  • document the payment endpoints in the README

/claim #1

Tests

  • npx bun test tests/routes/payments-default-middleware.test.ts tests/routes/payments.test.ts
  • npx bun test
  • npx bun run build
  • npx tsc --noEmit
  • npx biome check README.md lib/db/schema.ts lib/db/db-client.ts lib/middleware/with-db.ts lib/payments/route-schemas.ts routes/payments tests/routes/payments.test.ts tests/routes/payments-default-middleware.test.ts
  • git diff --check

AI-assisted with Codex; I reviewed the diff and kept the PR scoped to the bounty API.

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

ℹ️ 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 lib/middleware/with-db.ts
import { createDatabase } from "lib/db/db-client"
import type { Middleware } from "winterspec"

const defaultDb = createDatabase()
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 Scope default DB instance per app context

Move DB initialization out of module scope: creating defaultDb once at import time makes all routes that rely on withDb share state across the entire process, so separate Winterspec bundles or test runs in the same process can see each other’s payments/things and become order-dependent. This introduces cross-instance data bleed rather than just per-request persistence.

Useful? React with 👍 / 👎.

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