Files
loki/scripts
Mao NakamotoandClaude Opus 4.8 88635f8dd2 feat(billing): OrangeCat-rail Phase 1 (FC-side) — BTC-pass entitlement
The FleetCrown half of getting paid in Bitcoin through OrangeCat (no merchant
account, so unblocked by incorporation). Inert-but-ready until the OC-side
settlement signal + shared secret exist — nothing changes for users today.

- schema: users.plan_expires_at (BTC passes are time-boxed); oc_billing_grants
  ledger (external_id UNIQUE = idempotency + audit, mirrors Cat Credits' pattern).
  Applied as additive DDL to local + box; drift guard green (51 tables/516 cols).
- POST /api/orangecat/entitlement: HMAC-verified (ORANGECAT_WEBHOOK_SECRET,
  fail-closed 503 until set), maps OC actor → FC user, records the grant
  idempotently, then flips the plan via the SAME updateUserBilling the Stripe
  webhook uses + sets the expiry. HMAC round-trip + idempotency + downgrade all
  unit-tested against the DB (6/6).
- crons/downgrade-expired-plans (daily 09:30): reverts lapsed passes → free;
  Stripe subs (null expiry) untouched. Registered in install-hetzner-crons.sh.
- pricing: paid CTAs offer "Pay in Bitcoin" when a tier's OC pass URL is set
  (orangeCatPayUrl, env-driven like isStripeReady) — no dead links otherwise.
- grant path (scripts/grant-plan.ts) + updateUserBilling now carry planExpiresAt.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-14 03:03:10 +02:00
..