Module: Billing
Composable usage metering, invoice generation, and payment processing with Stripe. Records usage events with per-metric tracking, aggregates by customer and billing period, generates invoices with tiered pricing, and processes payments through a pluggable provider registry. Ships with a Stripe provider and an in-memory mock for testing.
| Name | module-billing-ts |
| Version | 0.1.0 |
| Category | composable-modules |
| License | Apache-2.0 |
| Persona | engineering |
| Tags | billing, payments, stripe, metering, invoicing, typescript |
| Source | templates/module-billing-ts |
Render it
Three front doors, one catalog. Pick whichever suits the caller.
# CLI
npx @nanohype/sdk render module-billing-ts --out ./my-app
# SDK
import { LocalSource, renderTemplate } from "@nanohype/sdk";
const result = await renderTemplate(source, "module-billing-ts", variables);
# MCP — from an agent
get_template({ name: "module-billing-ts" })Prerequisites
| Tool | Version | Why |
|---|---|---|
node | >=22 | Node.js runtime for the billing module |
Variables
Required
ProjectNamestring- Kebab-case project name, used as package name and directory Must be lowercase kebab-case starting with a letter.
Optional
Descriptionstring — defaults toUsage metering and billing with Stripe- Short project description for package.json and README
PaymentProviderstring — defaults tostripe- Default payment provider (stripe, mock, or a custom name)
What it produces
31 files. Placeholder names such as __APP_NAME__ are what the renderer substitutes into.
.env.example
.gitignore
biome.json
package.json
README.md
src/billing/__tests__/invoicing.test.ts
src/billing/__tests__/metering.test.ts
src/billing/__tests__/registry.test.ts
src/billing/__tests__/webhook.test.ts
src/billing/bootstrap.ts
src/billing/config.ts
src/billing/index.ts
src/billing/invoicing/formatter.ts
src/billing/invoicing/generator.ts
src/billing/invoicing/types.ts
src/billing/logger.ts
src/billing/metering/aggregator.ts
src/billing/metering/tracker.ts
src/billing/metering/types.ts
src/billing/metrics.ts
src/billing/providers/index.ts
src/billing/providers/mock.ts
src/billing/providers/registry.ts
src/billing/providers/stripe.ts
src/billing/providers/types.ts
src/billing/resilience/__tests__/circuit-breaker.test.ts
src/billing/resilience/circuit-breaker.ts
src/billing/types.ts
src/billing/webhooks/handler.ts
tsconfig.json
vitest.config.tsComposes with
- Pairs with
ts-service - Pairs with
module-webhook-ts - Pairs with
module-queue-ts - Nests inside
monorepo
Composites that use it
- AI Platform — Full AI platform with HTTP service, LLM gateway, vector store, data pipeline, auth, billing, and monitoring.