billingsdk

One billing SDK.
Every provider.

A unified TypeScript API for Stripe, Polar, Lemon Squeezy, Paddle, and Creem โ€” checkout, subscriptions, entitlements, usage metering, and webhooks.

$npx billingsdk initโŒ˜C
6
Provider adapters
0
Runtime dependencies
100%
TypeScript

Features

Designed for billing.
Built for TypeScript.

Every adapter implements the same interface. Learn once, deploy anywhere.

โ‡„

Provider-agnostic API

Swap Stripe for Polar or Lemon Squeezy by changing one import. Same interface for checkout, subscriptions, and webhooks.

๐Ÿ“

Declarative plans

Define prices, features, and limits in one place. Type-safe plan IDs and feature keys with full autocomplete.

โœ…

Entitlement checks

Check if a customer can access a feature in one line. Boolean flags or monthly-limit meters with remaining count.

๐Ÿ“Š

Usage metering

Track and enforce per-customer usage. Works with Stripe meter events or local storage โ€” same interface either way.

โšก

Normalized webhooks

Every provider emits the same event shapes. Built-in signature verification so you never miss a subscription event.

๐Ÿงช

Test adapter

Deterministic billing in tests with zero API calls. Assert checkout URLs, inspect created subscriptions, mock webhooks.

Code

One interface.
Every provider.

Define your plans once. The same code works with Stripe, Polar, Lemon Squeezy, and more.

setup.ts
import { createBilling, definePlans } from "billingsdk-core" import { stripe } from "billingsdk-stripe" const plans = definePlans({ free: { prices: [], features: { ai_generations: { limit: 10 } }, }, pro: { prices: [{ id: "pro-monthly", amount: 2000, currency: "usd", interval: "month" }], features: { ai_generations: { limit: 1000 } }, }, }) const billing = createBilling({ adapter: stripe({ secretKey: process.env.STRIPE_SECRET_KEY! }), plans, })
usage.ts
// Create a checkout session const checkout = await billing.checkout.create({ plan: "pro", successUrl: "https://example.com/success", }) // Check entitlements const { allowed, remaining } = await billing .entitlements.check({ customerId: "cus_123", feature: "ai_generations", }) // Report usage await billing.usage.report({ customerId: "cus_123", meter: "ai_generations", quantity: 1, })

Ship it

Ready to ship billing?

npm install billingsdk-core billingsdk-stripe