caelum0x 65bf2849ae feat(RCD-MON): fix recoder.xyz payment path -- checkout, webhook, entitlement
- POST /api/checkout creates a live Dodo checkout session from an allowlisted
  product slug (weekly/monthly/pro/pro_annual/team), never a client-supplied
  product id.
- POST /api/webhooks/dodo verifies the Standard Webhooks signature
  (webhook-id.webhook-timestamp.body, 5-min replay window) against a secret
  stored only as a Worker secret, records each delivery idempotently by
  webhook-id in D1, and upserts a per-customer entitlement row on
  subscription lifecycle events.
- GET /api/entitlement is an internal-only lookup gated by a shared-secret
  header, for Recoder's app / Rithub to check a customer's billing state.
- GET /api/portal resolves a checkout session's email, looks up the Dodo
  customer id from our own entitlements table, and redirects into Dodo's
  hosted customer portal -- no bespoke billing UI.
- New /thanks page with a "Manage subscription" link; pricing cards now
  trigger checkout via one click (no form -- Dodo's hosted page collects
  email/card).
- New D1 database recoder-billing (webhook_events + entitlements tables).

This re-points recoder.xyz at a real backend: the live Dodo webhook
(ep_3L0eElSCHnxNsth2aIBRdObJJzT) was 404ing against the old pure-static
site. Verified live: bad signature -> 401, correctly-signed test event ->
200 + D1 row + idempotent replay, all 5 live checkout URLs return 200 on
Dodo's hosted page, pricing/thanks screenshot clean at 1440 and 390 with
no console errors.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-12-01 16:14:37 +03:00
..