Skip to content

Add payment lifecycle API with idempotent send support#21

Open
JYZ-LESLIE wants to merge 1 commit into
tscircuit:mainfrom
JYZ-LESLIE:codex/add-payment-lifecycle-api
Open

Add payment lifecycle API with idempotent send support#21
JYZ-LESLIE wants to merge 1 commit into
tscircuit:mainfrom
JYZ-LESLIE:codex/add-payment-lifecycle-api

Conversation

@JYZ-LESLIE
Copy link
Copy Markdown

Summary

  • add fake payment routes: send, list, get, complete, and cancel
  • add payment schema + database helpers for lifecycle/state transitions
  • support idempotency keys in POST /payments/send to make retries safe
  • add end-to-end route test covering lifecycle and idempotent replay behavior
  • document the new payment routes in README

Validation

  • Could not run tests in this environment because bun is not installed.

/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: 4f49104ab4

ℹ️ 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/send.ts
})(async (req, ctx) => {
const body = sendPaymentBodySchema.parse(await req.json())

if (body.idempotency_key) {
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 Handle empty idempotency keys consistently

The replay guard uses a truthiness check (if (body.idempotency_key)), but the request schema allows idempotency_key: "" because it is z.string().optional(). In that case, the deduplication branch is skipped and repeated POST /payments/send calls with the same empty key create duplicate payments, which breaks the endpoint’s advertised idempotent retry behavior for this input.

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