carlos / platform Public

docs: billing for operators and owners, and carlos billing house (plans 6b)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 7be96246fdbb2b85a0e43e9aa736760ad2cf8430 parent db9e59b
1 file changed, +77 −3
  • docs/site/plans.md +77 −3
diff --git a/docs/site/plans.md b/docs/site/plans.md
index ff44de685..8654bd99b 100644
--- a/docs/site/plans.md
+++ b/docs/site/plans.md
@@ -124,7 +124,7 @@ Paying again turns everything back on straight away. The console records the cha
## Billing (operators)
-Billing keeps each paying account's plan in step with its subscription at Stripe. When a subscription is paid, the account is on the plan and packs it bought. When the subscription ends, the account goes back to the default plan, and a fall from a paid plan or pack starts a lapse exactly as described above. Nobody can buy anything through the console yet: checkout, pack changes and the billing page come later. Until then, this section is for operators setting billing up in test mode.
+Billing keeps each paying account's plan in step with its subscription at Stripe. When a subscription is paid, the account is on the plan and packs it bought. When the subscription ends, the account goes back to the default plan, and a fall from a paid plan or pack starts a lapse exactly as described above. Owners buy and change plans on the account's billing page, described in [Billing (owners)](#billing-owners) below. Billing is dormant until an operator sets it up, and this section is for that operator.
Billing is off unless you turn it on, and it needs plans: `CARLOS_BILLING` without `CARLOS_PLAN_CATALOG` stops the console at start. Nothing switches billing on by itself.
@@ -135,16 +135,25 @@ Every billing setting lives in the console's EnvironmentFile. None of them is a
| Variable | What it holds |
| --- | --- |
| `CARLOS_BILLING` | `off`, `test` or `live`. Unset is `off`. |
+| `CARLOS_PLAN_CATALOG` | The plan catalog. Billing needs one, as above. |
| `CARLOS_PRICE_BOOK` | The path to the price book file. |
| `CARLOS_BILLING_PRICES` | A JSON object from each price key to its Stripe price id. |
| `CARLOS_STRIPE_SECRET_KEY` | A restricted key: `rk_test_` in test mode, `rk_live_` in live mode. |
| `CARLOS_STRIPE_ACCOUNT` | The Stripe account the key belongs to (`acct_`). |
| `CARLOS_STRIPE_WEBHOOK_SECRET` | The webhook signing secret (`whsec_`). |
| `CARLOS_STRIPE_PREVIOUS_WEBHOOK_SECRETS` | Optional. Up to two older signing secrets, comma separated, while you rotate. |
+| `CARLOS_STRIPE_PORTAL_CONFIGURATION` | Required with billing on. The id (`bpc_`) of a Stripe customer portal configuration that allows cards and invoice history and nothing else. |
+| `CARLOS_STRIPE_HOUSE_COUPON` | Optional. The id of the coupon that makes a house account's checkout free. |
If any of them is wrong, the console refuses to start and names the variable, never its value.
-Point Stripe's webhook at `https://<console>/billing/webhook`. When the console starts, it checks the account and every price in the book against Stripe before it accepts a webhook. Until that check passes, the webhook answers 503 and Stripe tries again later, so a console that starts while Stripe is unreachable catches up by itself.
+Point Stripe's webhook at `https://<console>/billing/webhook`. When the console starts, it checks the account, every price in the book, the portal configuration and the house coupon (if you set one) against Stripe before it accepts a webhook. Until that check passes, the webhook answers 503 and Stripe tries again later, so a console that starts while Stripe is unreachable catches up by itself.
+
+### The portal and the house coupon
+
+Owners reach Stripe's customer portal from the billing page, to update a card or read an invoice. In the Stripe Dashboard, make a portal configuration that allows payment method updates and invoice history, and turns off plan changes and cancellation. Put its id in `CARLOS_STRIPE_PORTAL_CONFIGURATION`. The console refuses to start with billing on if the variable is missing, and the start-up check refuses a configuration that lets customers change or cancel a subscription, because those changes would bypass the console.
+
+The house coupon is a coupon you create in Stripe: 100% off, forever, for all products, with no redemption limit and no deadline. The start-up check refuses any other coupon. Without `CARLOS_STRIPE_HOUSE_COUPON`, you can still mark house accounts, but their checkout is refused.
### The price book
@@ -164,7 +173,7 @@ carlos billing problems -all # closed ones too
carlos billing close -id 12 -note "refunded and cancelled in the dashboard"
```
-The console can't close a problem while Stripe can still charge the subscription, an unpaid one included, and it can't see refunds, so your note is the record of what you did.
+The console can't close most problems while Stripe can still charge the subscription, an unpaid one included, and it can't see refunds, so your note is the record of what you did. The last four reasons in the table are about a subscription that is live, so they close while it is.
| Reason | What it means | What to do in Stripe |
| --- | --- | --- |
@@ -176,3 +185,68 @@ The console can't close a problem while Stripe can still charge the subscription
| `mode_mismatch` | A test-mode subscription reached a live console, or the other way round. | Check the webhook endpoints in each mode. |
| `discovery_failing` | For a day, the console has failed to read the subscriptions of a customer whose purchase it may have missed. It keeps trying every hour, and closes the problem itself once a read succeeds. | Check the customer in Stripe. If a subscription is paid, find out why the console can't read it. |
| `subscription_missing` | Stripe has no record of the account's current subscription. The account keeps its paid limits while the problem is open. | Find out what happened to it. Closing the problem while Stripe still has no such subscription ends it in the console and moves the account to the default plan. |
+| `seats_unpaid` | A team account has more members than the seats it has paid for this year. The owners' billing page says so and asks them to remove members or ask an operator. | Nothing needs doing in Stripe. Ask the owners to remove members. The console closes the problem itself once the members are at or below the paid seats. Closing it by hand works only then too, and is refused while the account is still over. |
+| `operation_unresolved` | The console sent Stripe a change (a pack, an upgrade, a seat, or a renewal switch) and never learned whether it happened. It will not send it again, because that could charge twice. The owners' billing page says the change is being checked. | Open the Dashboard's request log and find the request. Its idempotency key is `op:` followed by the operation id in the problem's detail. Close the problem with a note that starts with `executed` or `not-executed`, then what you saw. If the subscription already shows the change, the close just goes ahead. With `executed`, the close is refused until the subscription really shows it: put it right in the Dashboard first. With `not-executed`, the console drops the change and the owners can ask again. |
+| `restore_after_renewal` | An account took a pack or seat back up to what it had paid for, but Stripe applied it after the renewal that should have billed it. The subscription holds more than the renewal charged for. | Compare the subscription with the renewal invoice. Either charge the difference or put the quantity back, then close the problem with a note. |
+| `restore_check_stalled` | The console has not been able to check that renewal against the subscription for seven days. | Do the same comparison by hand, then close the problem with a note. |
+
+### House accounts
+
+A house account is one you run yourself. Its checkout carries the house coupon, so it pays nothing. Mark and clear one from the CLI, as an operator:
+
+```sh
+carlos billing house -account bac -on -note "our own shop"
+carlos billing house -account bac -off -note "now a customer"
+```
+
+Give `-account` the account's sqid, exactly one of `-on` and `-off`, and a `-note` saying why. The note is kept with who set it and is written to the console log. The mark applies when the account starts a checkout. It does not change a subscription the account already has. Clearing an account that isn't marked is not an error. This command works only against a console, not a bucket, and only for operators.
+
+## Billing (owners)
+
+Where billing is on, an account's owners buy and change their plan on the account's Billing page, at `/a/<account>/billing`. Members can open the page and read it, but only an owner can change anything. If an operator set the account's plan, there is nothing to buy.
+
+### Buying a plan
+
+Under **Choose a plan**, pick a currency (`usd`, `eur` or `gbp`), a plan, and any packs, then press **Continue to payment**. You go to Stripe to pay. When you come back, the page shows your new plan as soon as the payment is confirmed. Prices are for a year, and tax is added where it applies.
+
+The currency is fixed by the first purchase. After that the page says which currency the account pays in, and changing it means asking an operator.
+
+### Packs
+
+A pack raises one limit, such as apps or storage. Each pack has a number box and a **Change** button.
+
+- **Raising** a pack charges you now, for the rest of the year, plus any tax. Before anything is charged, you see a page headed **Pay for this change?** with the estimate. **Pay now** charges your card and the new limit applies at once. You may be asked to sign in again first.
+- **Lowering** a pack charges nothing and refunds nothing. The pack keeps its limits until the plan renews, and the next renewal bills the smaller amount.
+- **Buying back** a pack you lowered, up to what you already paid for this year, costs nothing more. It is refused within a day of renewal, because the renewal is about to bill the lower amount. Try again after it renews, and the pack is then an ordinary purchase.
+- **Upgrade to** a bigger plan charges the difference for the rest of the year, the same way.
+
+Only one change runs at a time. If you start another while one is being confirmed or paid for, the page asks you to finish or wait.
+
+### Members and seats on team plans
+
+A team plan is priced per member a year, with a minimum number of members. You pay for one seat per member, or the minimum if that is higher.
+
+- **Inviting** someone who would need a new paid seat shows what the seat will cost: "When *name* joins, the account pays about *amount* now for the rest of the year, plus any tax." Confirming the invite authorises that one seat. Nothing is charged until the person joins.
+- **Joining** uses a seat the account has already paid for first. A new seat is paid for with the invite's authorisation. If the payment doesn't go through, the join waits: the person sees a page saying the account can't add them yet, and the owners see why on their billing page. The person can open the same link again later.
+- **Removing** a member lowers the seats from the next renewal, with no refund. If that didn't go through, the page says "Your next renewal bills 12 seats for 10 members." and offers **Match seats to members**, which lowers the seats to the members now.
+- If the account ever has more members than seats, the page says "This account has more members than it pays for." Remove members, or ask an operator.
+
+### Confirm now
+
+If the page says it couldn't confirm a change or a payment page, it offers **Confirm now**. Pressing it asks Stripe what happened and shows the result. It never charges anything again. If that still can't settle it, the console opens a billing problem for an operator, and the page says someone is checking.
+
+### Continue to payment and Start over
+
+If you leave Stripe's payment page without paying, the Billing page says "Your payment page is still open." **Continue to payment** takes you back to it. **Start over** throws it away and begins a new purchase, with the plan and packs you chose. A payment page that has expired says so and asks you to start again.
+
+### Stopping and resuming renewal
+
+**Stop renewal** keeps the plan until the paid year ends and then moves the account to the free plan. The page says "Your plan ends on *date*." Anything the free plan doesn't cover is handled as described in [When a plan lapses](#when-a-plan-lapses). **Turn renewal back on** undoes it any time before then. Neither charges anything.
+
+### Deleting a paid account
+
+An account can't be deleted while it is still set to renew, or while a payment is being collected or a change is being confirmed. Stop renewal first, settle any payment under Payment and invoices, then delete the account. Deleting an account that never bought anything works as it always has.
+
+### Payment and invoices
+
+**Payment and invoices** opens Stripe's page for the account's cards and invoices. It does nothing else: you can't change the plan, a pack or the renewal there. Use it to update a card when the page says your last payment didn't go through (your plan stays while Stripe retries), or to pay a change that is waiting for payment, which is dropped after a day if nobody pays it. It shows once the account has bought something, and you may be asked to sign in again before it opens.