Billing
Billing lets your app sell. You list products, each with a price at your payment processor and what it grants
(instances: 1, seats: 5). A user checks out, pays on the processor's page, and comes back. Billing keeps every
subscription and order in step with the processor, and your code asks one question: what does this user have?
// pb_pages/upgrade.ts: start a checkout and send the browser there
module.exports = {
async post(ctx) {
if (!ctx.auth) return ctx.res.redirect('/login')
const { url } = await $billing.checkout.async(ctx.auth, { product: 'pro' })
return ctx.res.redirect(url)
},
}
// what the user has, from Go
ent, err := billing.For(app).Entitlements("users", userId)
// ent.Totals["seats"] == 5
What you get
- Products in your app's database, each mapped to a price at one or more processors.
- Checkout for signed-in users, or for visitors before they have an account (pay first).
- Webhooks that are checked against the processor: Billing reads each subscription or order back from the processor and writes what it finds, so a webhook that arrives twice or out of order changes nothing.
- Entitlements: the sum of what each user's active purchases grant, for gating features.
- A Billing page in the dashboard: products, customers, every item with its actions (cancel, resume, change quantity, refund, sync), manual grants, and webhook errors.
- Customer self-service through the processor's portal (cards, invoices) and Billing's own cancel, resume, quantity and plan calls.
Payment processors
Billing doesn't take payments itself. A processor extension does, and you install the ones you use:
| Processor | Merchant of record | Checkout |
|---|---|---|
| Stripe | You, or Stripe with Managed Payments | Stripe Checkout |
| Paddle | Paddle | Paddle.js overlay on a page Billing serves |
| Creem | Creem | Creem's hosted checkout |
A merchant of record sells to the buyer in its own name: it collects and files sales tax and VAT and handles disputes. Several processors can be installed at once; one takes new checkouts and the others keep renewing what was sold through them. See Payment processors.
Not in the stock binary
Billing and its processors are community extensions. The pocketone binary you install doesn't include them, so an
app that sells is a small custom build: a Go main.go that adds them to the standard set. Add Billing to your
app walks through it.
Questions and comments
Comments are a GitHub Discussions thread; sign in with GitHub to post.