PocketOne alpha.15: get paid
PocketOne v0.0.1-alpha.15 adds Billing with Stripe, Paddle and Creem, moves to PocketBase v0.43.0, and brings Go contexts to JS.
This one is about money. Your app can sell things now.
Billing. Billing sells subscriptions and one-time purchases through Stripe, Paddle or Creem. You set up products and prices, send people to checkout, and Billing keeps track of who has what. Webhooks don't get trusted on their own. Billing reads the purchase back from the processor before it changes anything, and a daily reconcile catches anything that slipped. There's a Billing page in the dashboard for products, customers and manual grants, and $billing in your pages:
// pb_pages/upgrade.ts
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)
},
}
and $billing.entitlements(ctx.auth) tells you what they have.
Somebody can also pay first and get an account after, which is how a lot of people actually want to buy. Billing isn't in the stock pocketone binary. Apps that sell add it, and the processors they use, in a small custom build. Add Billing to your app walks through it.
PocketBase v0.43.0. Apps pass Go contexts with app.WithContext(ctx) now, and an OAuth2 sign-in that finishes from a different IP gets a confirmation page instead of an error. If you have a custom Go build, there are some renames (SaveWithContext(ctx, m) becomes WithContext(ctx).Save(m) and so on).
Go contexts in JS. Since PocketBase went all in on contexts, so did the JS side. new TimeoutContext(30) and new CancelContext() stop work early, and they work everywhere: $app.withContext(ctx), fn.async(ctx, ...), $llm.withContext(ctx) and $wasm.withContext(ctx). AbortController, AbortSignal and asyncWith are gone.
Bulk Mail. Recipients get checked again right before a campaign sends, so somebody you deleted after you queued it doesn't get the email. There's a Links URL setting for apps whose Application URL doesn't reach the API, and an option to unverify accounts when their address bounces or complains.
To upgrade, run pocketone upgrade. If your JS uses AbortSignal.timeout(60_000), switch to new TimeoutContext(60) and pass it as a context. $llm calls take it through $llm.withContext(ctx) instead of signal. The release notes have every step.