docs: Music and shared accounts plan
Pull request / title (pull_request) Successful in 1s
CI / test (pull_request) Successful in 1m24s
CI / image (apps/api/Dockerfile, t5de-hub-api) (pull_request) Skipped
CI / image (apps/web/Dockerfile, t5de-hub-web) (pull_request) Skipped

Plan for T5DE Music (an IMVU room music bot at music.t5de.dev, streams from radio.t5de.dev on Oracle Cloud), one account system with Discord sign-in and basic accounts, the hub as an OIDC provider, pluggable sources modelled on HorizonRadio's, and a payments backend shared by Music and the hub.
This commit is contained in:
dhkatz committed 2026-11-18 21:55:44 +00:00
1 parent cc6959082c
commit 7026194808
3 files changed
+494 -1

No files matched your search

+133
View File
@@ -0,0 +1,133 @@
# Payments (plan)
Status: proposal for review (2026-11-18). Nothing here is **Decided** yet; open decisions are at the end.
Paid offerings for Music now (docs/music.md, Paid tier) and for the hub later, through one billing backend. More
than one payment processor from the start, because T5DE has adult content and the mainstream processors forbid it,
while Music has none.
## Goals
- **One place** for prices, subscriptions and what people have paid for, keyed by the T5DE account (basic or member:
someone who only uses Music can pay).
- **Several processors**, chosen per merchant, behind one interface: switching one touches no app.
- **No card data** anywhere of ours: hosted checkout pages and portals only.
- **Apps ask one question**: does this account have entitlement X (for room Y)? They never talk to a processor.
## Where it lives
In the hub's API, next to accounts (a module, `billing`), because the customer is the account. It moves with
accounts if they're ever split out (`accounts.t5de.dev`, docs/music.md). Apps reach it through the hub's API with the
person's access token, and the hub tells them about changes over the same signed back-channel as `user.merged`.
```
music.t5de.dev ──checkout──► hub API (billing) ──hosted checkout──► processor (Stripe for Music)
▲ │ ▲ │
└── entitlement.changed ──┘ └──────────── webhooks ◄─────────────────┘
```
## Concepts
| | What |
| --- | --- |
| **Merchant** | Who sells, with its processor account: `music` and `t5de`. Products belong to one merchant and never mix, so a processor that bans adult content only ever sees Music's sales, and one merchant account being closed can't take the other's payments with it. |
| **Product, price** | What's sold and for how much (`music.room`, yearly). |
| **Customer** | An account at one merchant's processor: `(account, merchant) → processor customer ID`. |
| **Subscription** | Mirrored from the processor: status, period end, cancel at period end. |
| **Payment event** | Every webhook, kept as received. Unique by `(processor, event ID)`, so a replay changes nothing. |
| **Entitlement** | What apps check: `{account, key, scope, from, until, source}`, e.g. `music.room` scoped to a room. Made from subscriptions, from moderators' grants (gifts, testers; console, audited) and later from codes. |
Processing a webhook doesn't trust its order: it fetches the subscription's current state from the processor and
recomputes that account's entitlements from it. Late, repeated or reordered events then all end in the same place.
## Processor adapters
```ts
interface Processor {
checkout(customer, price, scope, returnURL): Promise<{ url: string }>;
portal(customer, returnURL): Promise<{ url: string }>;
cancel(subscription, { atPeriodEnd: boolean }): Promise<void>;
refund(payment, amount?): Promise<void>;
// Verifies the signature and maps the processor's event to ours.
webhook(request): Promise<BillingEvent | null>;
subscription(id): Promise<SubscriptionState>;
}
```
Webhooks arrive at `POST /api/v1/billing/webhooks/<processor>` on the hub's API. Processors retry for days, so a hub
outage only delays them.
## Processors
| Merchant | Candidates | Notes |
| --- | --- | --- |
| `music` | **Stripe** directly | 2.9% + 30¢ (US cards). We are the seller: sales tax and VAT are ours (Stripe Tax calculates; registering and filing are ours). EU VAT on digital services applies from the first sale to an EU consumer. |
| | **PayPal** (business account, micropayments pricing) | 4.99% + 9¢ once opted in (it applies to the whole account; standard is 3.49% + 49¢), so the cheapest for small charges, and familiar to buyers. We are the seller, as with Stripe. Same rules against infringing goods; known for sudden limits, funds held up to 180 days, and disputes that favour buyers of digital goods. Goods and services payments only, never friends and family. |
| | A **merchant of record** (Paddle, Polar, Stripe Managed Payments, which absorbed Lemon Squeezy) | About 5% + 50¢. They're the seller and handle tax everywhere. They review what they sell before onboarding, and a YouTube-based music service may not pass. |
| `t5de` | **Adult-friendly processors** (CCBill, Segpay, Verotel, Epoch) | Around 10-15% plus reserves, quoted per merchant. Their own content and age-verification rules (the hub's age checks help); read them before building anything adult that's paid. |
| | Crypto (self-hosted BTCPay Server) | No processor fees; an extra option, not the only one. |
## Pricing near cost
Card fees are mostly the fixed part, so small charges lose a lot:
| Charge | PayPal micropayments (4.99% + 9¢) | Stripe (2.9% + 30¢) | Merchant of record (5% + 50¢) |
| --- | --- | --- | --- |
| $1 a month | 14¢ (14%) | 33¢ (33%) | 55¢ (55%) |
| $10 a year | 59¢ (6%) | 59¢ (6%) | $1.00 (10%) |
| $5 of credits | 34¢ (7%) | 45¢ (9%) | 75¢ (15%) |
So: a yearly price (about $10 a room), or credits bought in $5 steps that pay $1 a month per room. A real $1 a month
only works on PayPal's micropayments pricing.
### Credits
Credits change the fees, not who will process them: processors approve what credits are spent on, so a processor
that won't sell Music's paid tier won't sell credits for it either. If we sell them:
- **Per merchant**: Music's credits are spent only on Music. Credits usable in the hub too would put T5DE's sales
through Music's processor (or the reverse), which undoes the separation above.
- **Never transferable or cashable**: credits that move between people or turn back into money start to look like
money transmission.
- **No expiry, and refunds of unspent credits on request**: some US states treat expiring prepaid balances like gift
cards, and EU buyers have withdrawal rights. A ledger (bought, spent, refunded) per account, not a balance column.
### Selling as an individual
- No company is needed to start: Stripe and the merchants of record accept individuals (sole proprietors), with a
tax ID (SSN in the US) and a bank account. Income goes on a personal return (Schedule C in the US), with
self-employment tax on the profit.
- **With Stripe directly** we are the seller: the receipts show a business name (a trade name, which some states
require registering as a DBA), and EU sales legally need the seller's name and address shown.
- **With a merchant of record** the merchant of record is the seller: buyers see its name, and it handles tax
everywhere.
- A single-member LLC later: state filing fees vary widely (some states also charge a yearly minimum tax), plus a
free EIN and a registered agent to keep a home address off public records. It shields personal assets from the
business's debts and contracts, but not from claims about what its owner did personally, such as infringement.
- An hour with an accountant before the first sale; this section isn't tax or legal advice.
## Lapses, refunds and chargebacks
- A failed renewal gets a grace period (7 days), then the room drops to the free tier. Nothing is deleted.
- A refund or chargeback ends the entitlement at once. Repeated chargebacks: no new checkouts for that account.
- Every grant, refund and revocation is in the audit log.
## Phases
1. **Entitlements without money**: tables, moderators' grants in the console, the back-channel to Music, and
Music's paid features behind `music.room`. Lets the paid tier be tested and given away before anyone pays.
2. **Music's processor**: the adapter, checkout, webhooks, a Billing page under Account on the hub, links from Music.
3. **T5DE's processor**, when the hub has something to sell.
4. **Credits and codes**; a merchant of record if tax work grows.
## Before taking money
Terms of service with a refund policy, a privacy policy, and the accountant's hour (Selling as an individual, above).
## Open decisions
- Music: PayPal (cheapest for $1 charges, what the popular community bot uses), a merchant of record (it's the
seller and handles tax; a refusal at onboarding costs nothing), Stripe directly, or IMVU credits (docs/music.md,
Paid tier). Several can run side by side behind the adapter interface.
- Yearly price or credits for the paid tier.
- Whether the Billing page lives only on the hub, or Music also shows its own subscriptions.