feat: Stripe webhook for per-document payment (issue #53) #77

Closed
pook wants to merge 1 commit from feature/stripe-document-webhook into main
Owner

Summary

  • Adds POST /api/webhooks/stripe endpoint with Stripe signature verification
  • Handles checkout.session.completed to update document status from pending_payment to paid
  • Adds pending_payment and paid to document status enum, plus stripeSessionId column
  • Unhandled event types return 200 without processing; invalid signatures return 400 with no DB side effects

Files Changed

  • packages/api/src/db/schema.ts — extended document status enum + added stripeSessionId column
  • packages/api/src/routes/stripe-webhook.ts — new webhook route handler
  • packages/api/src/index.ts — register webhook route
  • packages/api/tests/unit/stripe-webhook.test.ts — 9 unit tests covering all acceptance criteria

Test Plan

  • Invalid signatures return 400 with no database side effects
  • checkout.session.completed updates document status to paid
  • Missing documentId in metadata is handled gracefully
  • Documents not in pending_payment status are skipped
  • Unhandled event types return 200 without processing
  • All 9 unit tests passing

Closes #53

🤖 Generated with Claude Code

## Summary - Adds `POST /api/webhooks/stripe` endpoint with Stripe signature verification - Handles `checkout.session.completed` to update document status from `pending_payment` to `paid` - Adds `pending_payment` and `paid` to document status enum, plus `stripeSessionId` column - Unhandled event types return 200 without processing; invalid signatures return 400 with no DB side effects ## Files Changed - `packages/api/src/db/schema.ts` — extended document status enum + added stripeSessionId column - `packages/api/src/routes/stripe-webhook.ts` — new webhook route handler - `packages/api/src/index.ts` — register webhook route - `packages/api/tests/unit/stripe-webhook.test.ts` — 9 unit tests covering all acceptance criteria ## Test Plan - [x] Invalid signatures return 400 with no database side effects - [x] checkout.session.completed updates document status to paid - [x] Missing documentId in metadata is handled gracefully - [x] Documents not in pending_payment status are skipped - [x] Unhandled event types return 200 without processing - [x] All 9 unit tests passing Closes #53 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat: add POST /api/webhooks/stripe for per-document payment flow
Some checks are pending
agent-worker/pr-tests Running PR tests...
35073d06c5
Implements checkout.session.completed webhook handler that updates
document status from pending_payment to paid, enabling revenue-critical
paid document generation unlock (issue #53).

- Add pending_payment and paid to document status enum
- Add stripeSessionId column to documents table
- Create /api/webhooks/stripe route with signature verification
- Return 400 on invalid signatures with no DB side effects
- Return 200 + ignore for unhandled event types
- Unit tests (9 passing) covering all acceptance criteria

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

⚠️ No Test Suite Detected

Commit: 35073d06

No test script found in package.json. Add a test script to enable automated testing.

## ⚠️ No Test Suite Detected **Commit:** `35073d06` No `test` script found in `package.json`. Add a test script to enable automated testing.
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:20 -04:00
Some checks are pending
agent-worker/pr-tests Running PR tests...

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!77
No description provided.