Contents

Chapter 1

Features

This chapter covers the core features and capabilities of Billing Integration.

Features

  • Subscription plans — Free, flat-rate, and metered billing with monthly/yearly intervals
  • Customer management — Create customers, link to your internal user/tenant IDs
  • Usage metering — Record API calls, storage, compute with idempotency protection
  • Invoice generation — Automatic line items for base plan + metered usage
  • Webhook processing — Verify HMAC-SHA256 signatures, dispatch to typed handlers
  • Trial support — Configurable trial periods per subscription
  • Graceful cancellation — Cancel immediately or at period end
  • JSON persistence — Save/load state for development and testing

Requirements

  • Python 3.10+
  • No external dependencies (stdlib only)
Chapter 2

Quick Start

Follow this guide to get Billing Integration up and running in your environment.

Quick Start

bash
# Start the billing server with demo data
python src/main.py --init-demo

# Start on a custom port
python src/main.py --port 8001

Then try the API:

bash
# List available plans
curl http://localhost:8001/api/plans

# Create a customer
curl -X POST http://localhost:8001/api/customers \
  -H "Content-Type: application/json" \
  -d '{"email": "user@example.com", "name": "Acme Corp", "external_id": "tenant_123"}'

# Subscribe to a plan (use plan ID from /api/plans response)
curl -X POST http://localhost:8001/api/subscriptions \
  -H "Content-Type: application/json" \
  -d '{"customer_id": "cus_xxx", "plan_id": "plan_xxx", "trial_days": 14}'

# Record usage
curl -X POST http://localhost:8001/api/usage \
  -H "Content-Type: application/json" \
  -d '{"subscription_id": "sub_xxx", "quantity": 100, "idempotency_key": "req_001"}'

# Generate an invoice
curl -X POST http://localhost:8001/api/invoices/generate \
  -H "Content-Type: application/json" \
  -d '{"subscription_id": "sub_xxx"}'

API Endpoints

MethodPathDescription
GET/api/plansList active subscription plans
POST/api/customersCreate a billing customer
POST/api/subscriptionsSubscribe customer to a plan
POST/api/subscriptions/:id/cancelCancel a subscription
POST/api/usageRecord metered usage
POST/api/invoices/generateGenerate an invoice for a subscription
POST/api/webhooksProcess incoming webhook events
Chapter 3
🔒 Available in full product

Configuration

Chapter 4
🔒 Available in full product

Project Structure

You’ve reached the end of the free preview

Get the full Billing Integration and unlock everything.

All Chapters

Get the complete guide with every chapter unlocked, including code samples, diagrams, and best practices.

Full Tool Suite

Access all interactive tools with complete data, all workload profiles, and the full scenario library.

Source Files

Downloadable source code, configuration files, and working examples from every chapter.

Lifetime Updates

Free updates for life. Every new chapter, tool, and improvement included.

Buy Now — $29 →
📦 Free sample included — download another copy for the full product.
Billing Integration v1.0.0 — Free Preview