feat: add POST /api/checkout for one-time document payments #140

Closed
pook wants to merge 1 commit from feat/stripe-document-checkout into main
Owner

Summary

  • Adds POST /api/checkout endpoint that creates a Stripe Checkout Session with mode: payment for one-time document purchases
  • Accepts { documentType, email }, validates inputs (400 on invalid), checks STRIPE_SECRET_KEY (503 if missing)
  • Returns { sessionId, url } for frontend redirect to Stripe-hosted checkout
  • Success/cancel URLs read from CHECKOUT_SUCCESS_URL / CHECKOUT_CANCEL_URL env vars

Files changed

  • packages/api/src/routes/checkout.ts — new route handler
  • packages/api/src/services/stripe.ts — added createDocumentCheckoutSession(), isStripeConfigured(), document pricing config
  • packages/api/src/index.ts — registered /api checkout route
  • packages/api/tests/checkout.test.ts — 9 unit tests with mocked Stripe SDK

Test plan

  • Happy path: creates session, returns sessionId + url
  • Verifies Stripe called with mode: payment
  • 400 on missing/invalid documentType
  • 400 on missing/invalid email
  • 400 on malformed JSON body
  • 503 when STRIPE_SECRET_KEY unset
  • Accepts all three document types (privacy, tos, cookie)
  • TypeScript type check passes (tsc --noEmit)

Closes #42

🤖 Generated with Claude Code

## Summary - Adds `POST /api/checkout` endpoint that creates a Stripe Checkout Session with `mode: payment` for one-time document purchases - Accepts `{ documentType, email }`, validates inputs (400 on invalid), checks `STRIPE_SECRET_KEY` (503 if missing) - Returns `{ sessionId, url }` for frontend redirect to Stripe-hosted checkout - Success/cancel URLs read from `CHECKOUT_SUCCESS_URL` / `CHECKOUT_CANCEL_URL` env vars ## Files changed - `packages/api/src/routes/checkout.ts` — new route handler - `packages/api/src/services/stripe.ts` — added `createDocumentCheckoutSession()`, `isStripeConfigured()`, document pricing config - `packages/api/src/index.ts` — registered `/api` checkout route - `packages/api/tests/checkout.test.ts` — 9 unit tests with mocked Stripe SDK ## Test plan - [x] Happy path: creates session, returns sessionId + url - [x] Verifies Stripe called with `mode: payment` - [x] 400 on missing/invalid documentType - [x] 400 on missing/invalid email - [x] 400 on malformed JSON body - [x] 503 when STRIPE_SECRET_KEY unset - [x] Accepts all three document types (privacy, tos, cookie) - [x] TypeScript type check passes (`tsc --noEmit`) Closes #42 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Adds a Stripe Checkout Session endpoint with mode: 'payment' for
purchasing individual documents. Accepts { documentType, email },
validates inputs (400), checks STRIPE_SECRET_KEY (503), and returns
{ sessionId, url } for frontend redirect.

Closes #42

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Owner

Closed 2026-04-10 during pipeline triage.

Merge conflicts with current main were blocking the CEO agent's backlog view. The compliancebot repo had ~60 open PRs and 141 open agent-task issues. CEO couldn't see progress and kept duplicating work due to a git-push race in agent-worker (now fixed — runId threaded through dispatch pipeline for unique branch names).

Reopen / resubmit against current main if the work is still relevant. Shim /shim/ceo route now injects open issues + PRs into the CEO prompt and refuses dispatch when backlog exceeds 20.

Closed 2026-04-10 during pipeline triage. Merge conflicts with current main were blocking the CEO agent's backlog view. The compliancebot repo had ~60 open PRs and 141 open agent-task issues. CEO couldn't see progress and kept duplicating work due to a git-push race in agent-worker (now fixed — runId threaded through dispatch pipeline for unique branch names). Reopen / resubmit against current main if the work is still relevant. Shim `/shim/ceo` route now injects open issues + PRs into the CEO prompt and refuses dispatch when backlog exceeds 20.
pook closed this pull request 2026-04-10 15:08:15 -04:00

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot!140
No description provided.