From 219b08538f106869e8726f445e363d46baecd9b8 Mon Sep 17 00:00:00 2001 From: joshua Date: Tue, 3 Nov 2026 12:18:02 +0200 Subject: [PATCH] Billing tiers on the install page, plan picker on licences (1.6.2) - Install page shows the 12-month event-income band (Cross Events 2.0.2+), the tier it falls in with its price and founding price, and flags a licence whose plan is a different tier. - Licence card: Plan picker (Trial or Seed to Network). - Protocol doc: 14 income bands and eventIncome12m. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 18 ++++++++ backend/package-lock.json | 4 +- backend/package.json | 2 +- docs/hub-protocol.md | 12 ++++- frontend/package-lock.json | 4 +- frontend/package.json | 2 +- .../src/app/(hub)/customers/[id]/page.tsx | 15 ++++++- frontend/src/app/(hub)/installs/[id]/page.tsx | 12 ++++- frontend/src/lib/tiers.ts | 44 +++++++++++++++++++ frontend/src/lib/types.ts | 2 +- 10 files changed, 103 insertions(+), 12 deletions(-) create mode 100644 frontend/src/lib/tiers.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 09b2893..ab15fa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,24 @@ versions follow [Semantic Versioning](https://semver.org/). ## [Unreleased] +## [1.6.2] - 2026-11-03 + +### Added + +- **Billing tiers.** The install page's Licence box shows the plan, the site's **event income over + the last 12 months** (`income.eventIncome12m`, sent by Cross Events 2.0.2+; no donations or + sponsorships) and the tier that income falls in, with its price and founding price. It notes + when the licence's plan is a different tier. The tiers are in `frontend/src/lib/tiers.ts` + (the public prices are in crosscode-site `src/data/pricing.mjs`: change both together). +- **Plan on the licence card** (customer page): Trial or one of the eight tiers (Seed to Network). + A licence still on the old `standard` plan keeps it until it's changed. + +### Changed + +- Protocol doc: 14 income bands up to `over R10 000 000` (Cross Events 2.0.2), and + `eventIncome12m`. Older installs still send the old bands; their `over R100 000` can't be placed + in a tier. + ## [1.6.1] - 2026-10-30 ### Changed diff --git a/backend/package-lock.json b/backend/package-lock.json index 8a8cbe5..22235e1 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -1,12 +1,12 @@ { "name": "events-hub-backend", - "version": "1.6.1", + "version": "1.6.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "events-hub-backend", - "version": "1.6.1", + "version": "1.6.2", "hasInstallScript": true, "dependencies": { "@anthropic-ai/sdk": "^1.3.0", diff --git a/backend/package.json b/backend/package.json index 0f532b9..bb6a36a 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "events-hub-backend", - "version": "1.6.1", + "version": "1.6.2", "private": true, "description": "Cross Events Hub — API for managing Cross Events installs, licences and heartbeats", "main": "src/index.js", diff --git a/docs/hub-protocol.md b/docs/hub-protocol.md index 342c101..a30ae63 100644 --- a/docs/hub-protocol.md +++ b/docs/hub-protocol.md @@ -100,7 +100,8 @@ X-Hub-Signature: "paymentProviders": ["yoco", "payfast"], "campuses": false, // Site settings → Campuses on/off "campusCount": 0, // active campuses (0 while off; Cross Events 1.43.0+) - "income": { "last30d": "R5 001–R20 000", "allTime": "over R100 000" } + "income": { "last30d": "R5 001–R20 000", "allTime": "R150 001–R250 000", + "eventIncome12m": "R100 001–R150 000" } // eventIncome12m: Cross Events 2.0.2+ } } → 200 { @@ -131,7 +132,14 @@ X-Hub-Signature: clock are refused (`401 STALE_REQUEST`); a bad signature is `401 BAD_SIGNATURE`; an unknown or released install is `404 INSTALL_NOT_FOUND` (the install should show "Reconnect to Hub"). - **Income bands** (worked out on the install; the amount never leaves it): `R0–R1 000`, - `R1 001–R5 000`, `R5 001–R20 000`, `R20 001–R50 000`, `R50 001–R100 000`, `over R100 000`. + `R1 001–R5 000`, `R5 001–R20 000`, `R20 001–R50 000`, `R50 001–R100 000`, + `R100 001–R150 000`, `R150 001–R250 000`, `R250 001–R400 000`, `R400 001–R700 000`, + `R700 001–R1 000 000`, `R1 000 001–R2 500 000`, `R2 500 001–R5 000 000`, + `R5 000 001–R10 000 000`, `over R10 000 000`. Before Cross Events 2.0.2 the bands stopped at + `over R100 000`, and donations applied to a registration were counted twice. +- **`eventIncome12m`** (Cross Events 2.0.2+) is the band of the last 365 days' event income: + payments less refunds, without donations or sponsorships. Cross Code's licence tiers are billed + on it, so every tier edge is a band edge. Older installs don't send it. - The Hub keeps every heartbeat for 30 days, then one per install per day. ## 3a. Update request diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 4be995a..3c30b8c 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "events-hub-frontend", - "version": "1.6.1", + "version": "1.6.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "events-hub-frontend", - "version": "1.6.1", + "version": "1.6.2", "dependencies": { "lucide-react": "^0.536.0", "next": "^15.5.24", diff --git a/frontend/package.json b/frontend/package.json index 7965ff2..fbf1d57 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "events-hub-frontend", - "version": "1.6.1", + "version": "1.6.2", "private": true, "scripts": { "dev": "next dev -p 3200", diff --git a/frontend/src/app/(hub)/customers/[id]/page.tsx b/frontend/src/app/(hub)/customers/[id]/page.tsx index f34e50e..ea16077 100644 --- a/frontend/src/app/(hub)/customers/[id]/page.tsx +++ b/frontend/src/app/(hub)/customers/[id]/page.tsx @@ -6,6 +6,7 @@ import { useParams } from "next/navigation"; import { ArrowLeft, Copy, KeyRound } from "lucide-react"; import { api, errorText } from "@/lib/api"; import { ago, fmtDate } from "@/lib/format"; +import { PLANS } from "@/lib/tiers"; import type { Customer, Licence, LicenceStatus } from "@/lib/types"; import { Badge, Loading, Message, PageTitle } from "@/components/ui"; @@ -16,6 +17,7 @@ const dateInput = (d: string | null) => (d ? d.slice(0, 10) : ""); function LicenceCard({ licence, onSaved, setMsg }: { licence: Licence; onSaved: () => void; setMsg: (m: Msg) => void }) { const [form, setForm] = useState({ status: licence.status, + plan: licence.plan, expiresAt: dateInput(licence.expiresAt), graceDays: String(licence.graceDays), aiRand: String(licence.aiMonthlyCapCents / 100), @@ -32,6 +34,7 @@ function LicenceCard({ licence, onSaved, setMsg }: { licence: Licence; onSaved: method: "PUT", body: { status: form.status, + plan: form.plan, // End of the chosen day, South African time. expiresAt: form.expiresAt ? `${form.expiresAt}T23:59:59+02:00` : null, graceDays: form.graceDays, @@ -67,7 +70,15 @@ function LicenceCard({ licence, onSaved, setMsg }: { licence: Licence; onSaved: ? <>Used by {licence.install.url} · last heartbeat {ago(licence.install.lastHeartbeatAt)} : "Not used yet — enter this key in the church's Cross Events setup (or Site settings → Licence)."} -
+
+
+ + +

Shown on the church's Licence page. Founding discount: note it below.

+
setForm({ ...form, notes: e.target.value })} placeholder="e.g. paid annually, invoice #123" /> + setForm({ ...form, notes: e.target.value })} placeholder="e.g. founding church, paid annually, invoice #123" />
diff --git a/frontend/src/app/(hub)/installs/[id]/page.tsx b/frontend/src/app/(hub)/installs/[id]/page.tsx index 29ae619..5c58257 100644 --- a/frontend/src/app/(hub)/installs/[id]/page.tsx +++ b/frontend/src/app/(hub)/installs/[id]/page.tsx @@ -7,6 +7,7 @@ import { ArrowLeft } from "lucide-react"; import { api, errorText } from "@/lib/api"; import { ago, bytes, fmtDate, rand, randFine } from "@/lib/format"; import { usePaged } from "@/lib/paging"; +import { tierForBand, tierPrice } from "@/lib/tiers"; import type { AiHelperUse, AiMonth, AiStatus, Health, InstallEvent, InstallSummary, Licence, Stats } from "@/lib/types"; import { Badge, Loading, Message, PageTitle, Pager } from "@/components/ui"; @@ -43,6 +44,7 @@ export default function InstallPage() { if (!d) return msg ? : ; const h = d.health || {}; const s = d.stats || {}; + const tier = tierForBand(s.income?.eventIncome12m); const diskPct = h.disk && h.disk.totalBytes ? Math.round((h.disk.freeBytes / h.disk.totalBytes) * 100) : null; // One point per day for the last 30 days: registrations in the last 30 days, as reported. const daily = new Map(); @@ -94,7 +96,7 @@ export default function InstallPage() { - + {points.length > 1 && ( @@ -115,6 +117,14 @@ export default function InstallPage() { } /> + + + {tier && ( + {tier.name} · {tierPrice(tier)}{d.licence.plan !== tier.name && d.licence.plan !== "Trial" && (plan is {d.licence.plan})}} + /> + )} Change the licence → diff --git a/frontend/src/lib/tiers.ts b/frontend/src/lib/tiers.ts new file mode 100644 index 0000000..92417d2 --- /dev/null +++ b/frontend/src/lib/tiers.ts @@ -0,0 +1,44 @@ +// Cross Events licence tiers, billed on a site's event income over the last 12 months (the +// `eventIncome12m` band, Cross Events 2.0.2+). The public prices are in crosscode-site +// src/data/pricing.mjs: change both together. Every tier edge is also a band edge on the install +// (BAND_TOPS in hope-events backend/src/hub/report.js), so a band always falls in one tier. + +export type Tier = { name: string; upTo: number | null; monthly: number | null; founding: number | null }; + +export const TIERS: Tier[] = [ + { name: "Seed", upTo: 50_000, monthly: 350, founding: 230 }, + { name: "Sprout", upTo: 150_000, monthly: 550, founding: 360 }, + { name: "Grow", upTo: 400_000, monthly: 850, founding: 550 }, + { name: "Flourish", upTo: 1_000_000, monthly: 1350, founding: 880 }, + { name: "Harvest", upTo: 2_500_000, monthly: 2100, founding: 1370 }, + { name: "Abundance", upTo: 5_000_000, monthly: 3200, founding: 2080 }, + { name: "Movement", upTo: 10_000_000, monthly: 4800, founding: 3120 }, + { name: "Network", upTo: null, monthly: null, founding: null }, // priced per church, from R7 500 +]; + +/** Licence plans offered on a licence: the tiers, plus a trial. */ +export const PLANS = ["Trial", ...TIERS.map(t => t.name)]; + +/** The highest rand amount in a band label ("R100 001–R150 000" → 150000; "over R10 000 000" → Infinity). */ +function bandTop(band: string): number | null { + if (/^over /i.test(band)) return Infinity; + const parts = band.split("–"); + if (parts.length !== 2) return null; + const n = Number(parts[1].replace(/[^\d]/g, "")); + return Number.isFinite(n) && parts[1].trim() !== "" ? n : null; +} + +/** + * The tier a band falls in, or null when it can't tell. An older install's "over R100 000" can't + * be placed (it could be any tier from Sprout up). + */ +export function tierForBand(band: string | null | undefined): Tier | null { + if (!band) return null; + if (band === "over R100 000") return null; + const top = bandTop(band); + if (top == null) return null; + return TIERS.find(t => t.upTo == null || top <= t.upTo) || null; +} + +export const tierPrice = (t: Tier) => + t.monthly == null ? "priced per church" : `R${t.monthly.toLocaleString("en-ZA")}/month (founding R${t.founding?.toLocaleString("en-ZA")})`; diff --git a/frontend/src/lib/types.ts b/frontend/src/lib/types.ts index 11927e5..c061edb 100644 --- a/frontend/src/lib/types.ts +++ b/frontend/src/lib/types.ts @@ -61,7 +61,7 @@ export type Stats = { paymentProviders?: string[]; campuses?: boolean; campusCount?: number; - income?: { last30d?: string; allTime?: string }; + income?: { last30d?: string; allTime?: string; eventIncome12m?: string }; }; export type InstallEvent = { id: string; type: string; level: Problem["level"]; message: string; createdAt: string; resolvedAt: string | null; install?: { id: string; name: string; url: string } };