Some checks failed
ci / cargo test (abacus) (push) Has been cancelled
ci / cargo test (agent-runtime) (push) Has been cancelled
ci / cargo test (context-passport) (push) Has been cancelled
ci / cargo test (game-economy) (push) Has been cancelled
ci / cargo test (ledgerline) (push) Has been cancelled
ci / cargo test (mint) (push) Has been cancelled
ci / cargo test (rago) (push) Has been cancelled
ci / cargo test (relay) (push) Has been cancelled
ci / node suites (push) Has been cancelled
ci / cargo test (toolgate) (push) Has been cancelled
ci / cargo test (turnstile) (push) Has been cancelled
ci / cargo test (vend) (push) Has been cancelled
apps/gitea -> apps/rithub-server; compose services/containers renamed (rithub-server-app/postgres/act-runner) with explicit project name and volume names pinned to the exact existing Docker volumes (no data loss); our own GITEA_* compose/env var names -> RIT_*; new rit-admin CLI wrapper on railyard-box; giteaSession.mjs/giteaOAuth.mjs/giteaInfo.mjs -> ritSession/ritOAuth/ritInfo across 6 apps; GiteaForgeAdapter -> RitForgeAdapter + giteaSyncService/importGiteaRepos/syncGiteaRepos -> rit* in ritgram (tsc clean); apps/console/lib/gitea.ts -> lib/ritProvision.ts; Go internal/giteaclient -> internal/ritclient in rithub-async-import (go build/test clean); new /auth/rit + /forges/rit/connect routes with /gitea back-compat aliases; locale/swagger/footer/captcha template text scrubbed of remaining "Gitea" strings. Deployed to railyard-box: old containers stopped/removed, /srv/railyard-gitea renamed to /srv/rithub-server with a symlink kept, docker compose up -d from the new path, act_runner network-alias fix for its persisted instance URL. Live-verified: docker compose config diff showed zero unintended value changes, DB row counts unchanged (19 users, 635 repos), full route regression 200/expected, 0 "gitea" in headers/bodies on every checked page, real git clone+push over HTTPS and SSH with a disposable account (deleted after). Deferred on purpose (documented in plans/railyard.md): the forge discriminator / DB column names / Postgres role+volume names (data migrations, not a naming change) and the upstream GITEA__ env-to-ini keys and X-Gitea-* wire headers (hardcoded in the vendored engine binary). See plans/railyard.md RIT-OPS/RIT-BRD entry for the full old->new map and live evidence. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
92 lines
5.2 KiB
Markdown
92 lines
5.2 KiB
Markdown
# rithub-billing
|
|
|
|
Checkout + webhook for Rithub's self-serve paid plans, RIT-MON lane,
|
|
2026-11-30. Zero npm dependencies, same style as `rithub-mcp` next to it.
|
|
4 plans share one pipeline: `pro`/`pro-year` ($9/mo, $90/yr), `team`
|
|
($49/mo, 5 seats), `concierge` (one-time $149 migration service).
|
|
|
|
## Routes (served behind Caddy at `https://rithub.dev/billing/*`)
|
|
|
|
- `GET /billing/checkout?plan=pro|pro-year|team|concierge` -- creates a
|
|
live Dodo Payments checkout session for the allowlisted plan and
|
|
302-redirects the browser straight to `checkout_url`. No form, one click
|
|
from the pricing page.
|
|
- `POST /billing/webhook` -- verifies the Standard-Webhooks signature with
|
|
the real Dodo signing secret, then records the entitlement.
|
|
- `GET /billing/success` -- plain thank-you page, Dodo's `return_url`.
|
|
- `GET /billing/admin?token=...` -- owner-only JSON view of who currently
|
|
has an active/revoked/on_hold Pro entitlement (`customers`, keyed by Dodo
|
|
customer/email) and what that resolved to (`pro_users`, keyed by Rithub
|
|
login, from `rithub-lifecycle`). Token in `/etc/products/rithub-billing.env`
|
|
(`RITHUB_BILLING_ADMIN_TOKEN`).
|
|
- `GET /billing/status` -- `{ login, pro: bool, status }` for whichever
|
|
user the *request's own session cookie* resolves to (forwarded to
|
|
Rithub's `GET /api/v1/user` via `src/ritSession.mjs` -- never taken
|
|
from a query param, so it can't be used to probe any other username's
|
|
Pro/revoked/on_hold state). 401 if not signed in. Reads
|
|
`RITHUB_PRO_USERS_FILE`/`pro-users.json` only (never the entitlements
|
|
store directly -- that file has no login field). Backs the Pro/Free badge
|
|
on `/user/settings/*`, rendered by
|
|
`apps/gitea/custom/templates/custom/header.tmpl`.
|
|
- `GET /billing/health` -- `{ ok: true, configured: bool }`, no secrets.
|
|
|
|
## Who paid -> account, mails, Pro list (2026-11-30)
|
|
|
|
This service only records who paid (`data/entitlements.json`). The
|
|
`rithub-lifecycle` timer (every 15 min, `apps/rithub-lifecycle/rithub_pro.py`)
|
|
reads that file and:
|
|
- links each payment to the Rithub login with the same email;
|
|
- mails the customer once when Pro turns on, and mails the owner on every
|
|
status change (active / revoked / on_hold);
|
|
- writes `/var/lib/rithub-lifecycle/pro-users.json` (`{login: status}`).
|
|
|
|
Free has no repo/storage limits today, so there is no quota to raise -- Pro
|
|
does not and must not paywall anything that is free today.
|
|
|
|
**Team and concierge (2026-11-30):** same entitlements file, plan-tagged
|
|
(`"team"`/`"concierge"`, resolved server-side from the Dodo product id on
|
|
the webhook event, never trusted from client metadata). `pro-users.json`
|
|
only ever contains the real recurring `"pro"` plan -- Team has no seat
|
|
enforcement yet (same "ship the real promise, not an invented paywall"
|
|
rule as Pro) and concierge is a one-time service purchase, not a
|
|
Pro/Free state, so neither belongs on that settings banner. `rithub_pro.py`
|
|
mails the owner on every plan's status change (plan-labeled subject) and
|
|
sends a plan-correct customer mail -- concierge gets a short "we'll start
|
|
moving your repos" ack instead of the subscription "is on" copy, since
|
|
fulfilling it is a real follow-up task, not something this pass can grant.
|
|
|
|
**Enforcement wired 2026-11-30 (RIT-MON):** what the pricing page actually
|
|
promises Pro today is priority support and a visible Pro state, not a
|
|
quota -- so that is what is enforced. `/billing/status` answers "is this
|
|
login Pro" for `custom/header.tmpl`, which renders a real
|
|
active/free banner at the top of every `/user/settings/*` page (Free
|
|
banner links to `/pricing`, Pro banner states what Pro includes; no new
|
|
copy invented, both lines match the pricing page). The customer-mail copy
|
|
`rithub_pro.py` already sends ("priority support: reply to this email and
|
|
a person answers it first") is the real support-priority mechanism --
|
|
there is no separate ticket queue to gate. The next real Pro-only feature
|
|
(higher storage/repo limits, team seats) reads `pro-users.json` the same
|
|
way once it ships.
|
|
|
|
Source of truth for this code is this repo dir; the running copy is
|
|
`/home/deploy/apps/rithub-billing` on railyard-box (pm2 `rithub-billing`).
|
|
|
|
## Env (`/etc/products/rithub-billing.env`, never committed)
|
|
|
|
```
|
|
DODO_API_KEY= # shared live Dodo key (same business as the
|
|
# railyard-console billing note in plans/railyard.md)
|
|
DODO_WEBHOOK_SECRET= # secret for webhook endpoint ep_3MpCw0JeRqWxuKpTiWbm4sxZ2R6
|
|
DODO_PRODUCT_ID_PRO_MONTH= # pdt_0Nt4BZupcvdjUkspreaGW -- Rithub Pro, $9/mo
|
|
DODO_PRODUCT_ID_PRO_YEAR= # pdt_0Nt4BbVQtlx065dnL55Qd -- Rithub Pro yearly, $90/yr
|
|
DODO_PRODUCT_ID_TEAM= # pdt_0Nt5QOTvyRsIS2bzPTGMN -- Rithub Team, $49/mo, 5 seats
|
|
DODO_PRODUCT_ID_CONCIERGE= # pdt_0Nt5QOsTUXHh1p3KU6i8A -- Migration concierge, one-time $149
|
|
RITHUB_BILLING_ADMIN_TOKEN=
|
|
RITHUB_PRO_USERS_FILE= # optional, defaults to /var/lib/rithub-lifecycle/pro-users.json
|
|
RITHUB_BASE_URL= # optional, defaults to https://rithub.dev; set to
|
|
# http://127.0.0.1:3350 on railyard-box (same
|
|
# internal address rithub-mcp already uses) so
|
|
# /billing/status's session check hits the engine
|
|
# directly instead of round-tripping Caddy.
|
|
```
|