Phase 14, part 2: the owner's Billing page
Settings → Billing shows the team's plan, trial, people, agents, storage and next invoice. The owner subscribes through Stripe Checkout (monthly, or yearly when there's a price) and pays or reads invoices in Stripe's Customer Portal; admins see the plan only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -101,6 +101,8 @@ type state struct {
|
||||
rotation atomic.Uint64 // which team's turn comes first (eachTeam)
|
||||
patterns []string // every route's pattern
|
||||
|
||||
stripe *billing.Stripe // the platform's Stripe account (billing)
|
||||
|
||||
mu sync.Mutex
|
||||
copies map[int64]*Server // each team's Server
|
||||
caches map[int64]*teamCache // each team's tokens and lists kept a while
|
||||
@@ -343,6 +345,9 @@ func (s *Server) Handler() (http.Handler, error) {
|
||||
// Signing in (the server edition).
|
||||
mux.HandleFunc("GET /setup/{token}", (*Server).setupPage)
|
||||
mux.HandleFunc("POST /setup/{token}", (*Server).setupSave)
|
||||
mux.HandleFunc("GET /settings/billing", (*Server).billingPage)
|
||||
mux.HandleFunc("POST /settings/billing/checkout", (*Server).billingCheckout)
|
||||
mux.HandleFunc("POST /settings/billing/portal", (*Server).billingPortal)
|
||||
mux.HandleFunc("GET /settings/data", (*Server).dataPage)
|
||||
mux.HandleFunc("POST /settings/data/export", (*Server).dataExport)
|
||||
mux.HandleFunc("GET /settings/data/exports/{name}", (*Server).dataDownload)
|
||||
@@ -707,6 +712,7 @@ func (s *Server) loadTemplates() error {
|
||||
"xreserve": twitter.URLReserve,
|
||||
// money shows cents as dollars: $1,234 or $12.50.
|
||||
"money": money,
|
||||
"int64": func(n int) int64 { return int64(n) },
|
||||
// usd shows float cents as whole dollars: $9,835.
|
||||
"usd": func(cents float64) string { return money(int64(math.Round(cents/100)) * 100) },
|
||||
"mul12": func(f float64) float64 { return 12 * f },
|
||||
@@ -807,6 +813,7 @@ type page struct {
|
||||
Teams []users.TeamInfo // the viewer\'s teams (multi-tenant), for the switcher
|
||||
TeamID int64 // the team they\'re working in
|
||||
Multi bool // the multi-tenant edition
|
||||
Billing bool // teams are billed (multi-tenant)
|
||||
Viewer *viewer // who's looking
|
||||
}
|
||||
|
||||
@@ -887,7 +894,7 @@ func (s *Server) render(w http.ResponseWriter, r *http.Request, name string, p p
|
||||
p.Approvals = s.waitingFor(p.Viewer)
|
||||
p.Teams, p.TeamID = s.teamsOf(p.Viewer), s.team()
|
||||
}
|
||||
p.Multi = s.multi()
|
||||
p.Multi, p.Billing = s.multi(), s.billingOn()
|
||||
out, err := withCSRF(r, func(b *bytes.Buffer) error { return t.ExecuteTemplate(b, "layout.html", p) })
|
||||
if err != nil {
|
||||
s.Log.Error("render", "page", name, "err", err)
|
||||
@@ -951,6 +958,7 @@ var flashes = map[string]string{
|
||||
"exported": "Exported: %d rows. Download it below.",
|
||||
"undeleted": "The team won't be deleted: it's back as it was.",
|
||||
"secret-made": "The client's secret is made: add the entry below to the Core, then Test.",
|
||||
"subscribed": "Thank you: the subscription starts as soon as Stripe confirms it, in a minute.",
|
||||
"domain-released": "Released: another team can prove the domain now.",
|
||||
"invitations-resent": "Sent %d invitations again.",
|
||||
"view-needs-reason": "Give a reason and how long: it's recorded in the team's own log.",
|
||||
|
||||
Reference in New Issue
Block a user