Billing Rules as TypeScript Instead of Dashboard Glue

repotypescriptbillingstripeentitlementsusage-billingopen-source

code-defined plans and app-owned billing state map to joelclaw's preference for owned data and typed runtime boundaries

PayKit is a TypeScript billing framework that lives inside your app instead of making billing another haunted dashboard chore. You define features, plans, limits, prices, and usage rules in code, then wire it to Stripe and your own database.

The clever bit is the ownership boundary. PayKit handles the Stripe lifecycle and webhooks, but keeps billing state in your app database and exposes one API for products, subscriptions, entitlements, and usage billing. That’s the useful shape: provider integration without letting the provider become the source of truth for the whole business.

This is especially interesting for joelclaw because it has the same bias as the rest of the system: define the contract in code, own the state, keep the runtime boring. The example plan definitions are small, readable, and reviewable, which beats clicking through pricing logic in a dashboard and hoping nobody fat-fingered the monthly message limit.

It’s early-looking open source, but the frame is solid: billing as an embedded framework, not a SaaS-shaped tax on your architecture. Worth tracking if PayKit grows beyond Stripe and keeps the app-owned data model intact.

Key Ideas

  • PayKit defines billing products, plans, features, prices, and usage limits directly in TypeScript code.
  • The framework sits inside the app, uses the app’s database, and exposes one API for subscriptions, entitlements, products, and usage billing.
  • Stripe integration is handled through configured secret keys and webhook secrets, reducing the glue code normally built around the Stripe SDK.
  • Usage-based features can be modeled as metered features with limits and reset windows, like messages({ limit: 2_000, reset: "month" }).
  • The project is MIT licensed, published as paykitjs, and includes a CLI init path with npx paykitjs init.