Skip to content

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.

Namemodule-billing-ts
Version0.1.0
Categorycomposable-modules
LicenseApache-2.0
Personaengineering
Tagsbilling, payments, stripe, metering, invoicing, typescript
Sourcetemplates/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

ToolVersionWhy
node>=22Node.js runtime for the billing module

Variables

Required

ProjectName string
Kebab-case project name, used as package name and directory Must be lowercase kebab-case starting with a letter.

Optional

Description string — defaults to Usage metering and billing with Stripe
Short project description for package.json and README
PaymentProvider string — defaults to stripe
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.ts

Composes with

Composites that use it

  • AI Platform — Full AI platform with HTTP service, LLM gateway, vector store, data pipeline, auth, billing, and monitoring.