#Billing

Articles about Billing — exploring patterns, best practices, and real-world implementations in production systems.

8 posts tagged with billing. ← Blog home

#A/B Testing (3)#A2A (14)#ADK (8)#AG-UI (6)#AI (9)#AI Adoption (9)#AI Agents (355)#AI Architecture (22)#AI Cost (10)#AI Cost Optimization (8)#AI Engineering (316)#AI Evaluation (9)#AI Financial Engineering (14)#AI Gateway (8)#AI Governance (43)#AI Red Teaming (9)#AI Research (17)#AI Safety (12)#AI Security (35)#AI Strategy (8)#AI in Production (12)#AML (3)#API Design (17)#API Security (9)#APIs (69)#AWS (17)#Accountability (8)#Accounting (9)#Agent Memory (8)#Agent Skills (11)#Agentic AI (25)#Agentic Commerce (12)#Agentic Engineering (12)#Agentic RAG (8)#Agents (4)#Amazon Bedrock (8)#Analytics (3)#Architecture (45)#Attention (3)#Audit (4)#Authentication (11)#Authorization (3)#Automation (13)#Azure (11)#Azure AI Foundry (9)#Backend Engineering (322)#Benchmarks (3)#Best Practices (5)#BigQuery (6)#Billing (8)#Build Systems (4)#Business Finance (8)#Business Strategy (55)#C (8)#CI/CD (23)#Caching (11)#Capital Markets (14)#Card Payments (12)#Cards (13)#Career (30)#Causal Inference (8)#Cellular Automata (8)#Change Management (3)#Checkpointing (4)#Claude Code (8)#Cloud (5)#Cloud Architecture (3)#Cloud Native (10)#Code Review (9)#Coding Agents (20)#Collaboration (6)#Communication (9)#Complexity (8)#Compliance (54)#Computer Networking (9)#Computer Science (40)#Computer Vision (15)#Computer-Use Agents (8)#Concurrency (42)#Consulting (26)#Containers (10)#Context Engineering (19)#Conversational AI (8)#Cost Optimisation (5)#Cost Optimization (3)#Credit (16)#Credit Risk (16)#CrewAI (8)#Crypto (12)#Cryptocurrency (12)#Cryptography (9)#Custody (9)#DSPy (8)#Data (14)#Data Engineering (25)#Data Governance (3)#Data Science (8)#Data Structures (10)#Databases (48)#Deep Learning (20)#Deployment (5)#Design (3)#Design Patterns (10)#DevOps (24)#DevSecOps (22)#Developer Experience (7)#Developer Productivity (15)#Developer Tools (5)#Differential Privacy (3)#Diffusion Models (10)#Discovery (5)#Distributed Systems (104)#Documentation (3)#Edge AI (8)#Embeddings (21)#Emotional Intelligence (8)#Energy (8)#Engineering (14)#Engineering Culture (3)#Engineering Judgment (7)#Engineering Practices (21)#Enterprise AI (8)#Error Handling (4)#Evaluation (79)#Event-Driven (9)#Event-Driven Architecture (8)#Explainability (3)#Explainable AI (8)#FREE-AI (8)#FX (5)#Feature Engineering (3)#Feature Flags (3)#Feedback (4)#FinOps (23)#FinTech (6)#Financial AI (14)#Financial Engineering (8)#Financial Systems (133)#Fine-Tuning (12)#Fintech (134)#Flutter (8)#Forecasting (10)#Foreign Exchange (5)#Forward Deployed Engineer (43)#Forward Deployed Engineering (8)#Fraud (10)#Fraud Detection (8)#Function Tools (5)#Functional Programming (3)#Fundamentals (23)#Fundraising (8)#GCP (5)#GPU (8)#GUI Automation (8)#Gemma (4)#Generative AI (13)#Git (8)#Go (232)#Go-to-Market (31)#Google ADK (36)#Governance (61)#Granite (6)#Graph Neural Networks (8)#GraphQL (3)#Growth (3)#Guardrails (35)#HIPAA (3)#HTTP (3)#Harness Engineering (8)#Hiring (9)#Hugging Face (8)#Human-in-the-Loop (10)#IBM watsonx (8)#Idempotency (3)#Identity (11)#Image Generation (10)#Inference (8)#Information Retrieval (8)#Integration (3)#Integrations (8)#Intellectual Property (8)#Interfaces (3)#Interpretability (8)#JavaScript (8)#KYC (11)#KYC and AML (12)#Kafka (11)#Knowledge Graphs (11)#Kubernetes (17)#LLM (5)#LLM Inference (8)#LLM Infrastructure (8)#LLM-as-Judge (3)#LLMOps (9)#LLMs (197)#LangChain (8)#LangGraph (11)#Leadership (33)#Ledger (12)#Legal (8)#Lending (14)#Linux (9)#LlamaIndex (8)#Load Balancing (3)#MCP (25)#MLOps (39)#Machine Learning (119)#Marketing (16)#Markets (4)#Mathematical Finance (8)#Memory (16)#Memory Management (5)#Metrics (7)#Microservices (3)#Microsoft Agent Framework (150)#Middleware (6)#Migration (9)#Migrations (8)#Mixture of Experts (5)#Model Risk (3)#Monetization (9)#Monitoring (5)#Monorepo (3)#Multi-Agent (10)#Multi-Agent AI (14)#Multi-Agent Systems (76)#Multimodal (3)#Multimodal AI (11)#NIM (5)#NVIDIA (8)#Networking (3)#OAuth (3)#OWASP (7)#Observability (53)#On-Device AI (8)#Ontology (8)#Open Source (7)#OpenAPI (3)#OpenTelemetry (5)#Operating Systems (9)#Operations (14)#Opinion (6)#Orchestration (10)#Organizational Design (8)#Payment Rails (16)#Payments (55)#People (8)#Performance (56)#Personalization (9)#Platform Engineering (17)#Policy as Code (3)#PreSales (8)#Pricing (4)#Privacy (14)#Privacy Engineering (3)#Process (4)#Product (30)#Product Management (9)#Production (22)#Programming (10)#Programming Languages (48)#Prompt Engineering (86)#Prompt Injection (16)#Proof of Concept (3)#Protocol Buffers (3)#Protocols (9)#Providers (4)#Pydantic AI (8)#Python (142)#Quality (3)#Quantitative Finance (22)#RAG (72)#RBI (3)#REST (5)#Rails (16)#Real-Time (8)#Reasoning Models (8)#Recommender Systems (8)#Reconciliation (5)#RegTech (8)#Regulation (10)#Reinforcement Learning (9)#Reliability (68)#Resilience (4)#Responsible AI (5)#Retrieval (3)#Risk (22)#Risk Management (11)#Rust (32)#SLSA (3)#SRE (23)#SaaS (9)#Sales (9)#Sales Engineering (8)#Scalability (6)#Search (10)#Security (103)#Security Engineering (8)#Self-Evolving Agents (24)#Semantic Web (8)#Sessions (3)#Settlement (9)#Soft Skills (8)#Software (3)#Software Architecture (36)#Software Delivery (9)#Software Engineering (152)#Spanner (4)#Specification Engineering (3)#Speech (8)#Startups (30)#Statistics (8)#Strands (8)#Strategy (6)#Stream Processing (9)#Streaming (38)#Structured Output (4)#Supply Chain Security (10)#Sustainability (9)#System Design (32)#Systems Programming (56)#Technical Sales (6)#Testing (79)#Threat Modeling (3)#Time Series (9)#Tool Use (23)#Tooling (11)#Tools (4)#Trading (8)#Transformers (3)#Treasury (6)#Trust (4)#Type System (3)#Type Systems (12)#TypeScript (8)#Validation (3)#Valuation (3)#Vector Databases (23)#Vector Search (12)#Venture Capital (8)#Version Control (9)#Versioning (7)#Voice AI (9)#Web Development (6)#Webhooks (9)#Workflow (4)#Workflows (14)#eBPF (8)#gRPC (13)#smolagents (8)
Pratik Dhanave · ·4 min read

Revenue Integrity — Reconciliation, Recognition, and the Metrics Finance Will Compute Anyway

The billing system's last responsibility is proving itself: that every invoice matches money that actually moved, that revenue is recognized when it's earned rather than when it's charged, and that the metrics the business runs on — MRR, churn, net revenue retention — derive from billing data by defined rules rather than by whichever spreadsheet ran last. Revenue integrity is where billing engineering meets accounting, and the systems that skip it get audited into building it retroactively.

Revenue integrity closes the series: reconciliation across billing, processor, and settlement with a short owned exception queue; revenue recognition (charging is not earning — emit service periods and linkage so deferral is computable); and MRR with movements as versioned derivations from the state machine itself.

Pratik Dhanave · ·4 min read

Testing Billing Systems — Simulated Clocks and Golden Invoices

Billing's defining property — post 1 called it time-dominance — makes it nearly untestable by ordinary means: the interesting behavior happens at renewals, trial expiries, grace-window closures, and anniversary boundaries, none of which occur during a test run unless the test controls time itself. The teams that trust their billing systems all converged on the same answer: make the clock an injectable dependency, simulate months in milliseconds, and pin correctness with golden invoices.

Billing becomes testable when time becomes an injected dependency: simulated clocks drive month-long lifecycles in milliseconds, golden invoices pin the money to the cent with diffs as review artifacts, re-derivation audits check production continuously, and property tests cover the proration arithmetic.

Pratik Dhanave · ·4 min read

Entitlements — Decoupling What Customers Can Do from What They Pay

Scattered through most SaaS codebases is the same bug factory: `if plan == "pro"` checks guarding features. They work until the first pricing change, when "pro" splits into three plans, grandfathered customers keep old capabilities, sales grants an exception, and a trial needs temporary access — and suddenly product code is re-implementing billing logic badly. Entitlements are the missing layer: a dedicated system answering "may this customer do X?" so that product code never asks about plans at all.

Entitlements decouple what customers can do from what they pay: features (boolean, limit, quota), grants with sources and validity, and resolution behind one fast cached check — with plans demoted to versioned bundles. Pricing re-packages freely without product deploys, and exceptions become auditable.

Pratik Dhanave · ·4 min read

Invoicing and Collection — From State to Document to Money

The invoice is where billing's abstractions become a legal document and an attempted charge. Everything upstream — price versions, metered totals, prorations — converges into line items a human must be able to read and a regulator must be able to audit; then the system has to actually collect, which means confronting the fact that a meaningful fraction of payments fail. Invoicing is document engineering; collection is failure engineering; revenue requires both.

The invoice is an immutable derivation — re-derivable from versioned inputs, frozen at finalization, corrected only by new documents. Collection is failure engineering: dunning that distinguishes hard from soft declines, schedules retries deliberately, and treats the payment-update email as part of the machinery.

Pratik Dhanave · ·4 min read

The Subscription State Machine — Lifecycle, Proration, and the Edges Between

A subscription looks like a row with a plan and a date. It behaves like a state machine with a dozen states, transitions triggered by humans, payments, and the calendar, and money consequences on nearly every edge. Teams that model the lifecycle explicitly handle upgrades, trials, and cancellations as transitions with rules; teams that don't accumulate booleans — `is_trial`, `is_paused`, `cancel_at_period_end` — until no one can say what state a customer is actually in.

A subscription is a state machine — trialing, active, past-due, paused, canceled-now vs at-period-end — where every edge answers four questions: trigger, money, entitlements, clock. Proration arithmetic with encoded policies, and scheduled transitions as first-class records so future state is queryable.

Pratik Dhanave · ·4 min read

Metering — Counting Billions of Events Without Losing One

Usage-based pricing has a humble prerequisite: you must count correctly. Not approximately — correctly, at whatever volume success brings, across retries, duplicates, late arrivals, and clock skew, because every counted unit is money and every miscounted one is a dispute. Metering is stream processing where the aggregation result appears on an invoice, and that destination changes every engineering trade-off.

Metering is stream processing with invoice-grade obligations: deterministic source-minted idempotency keys, dedup at the door, event-time aggregation into exactly one billing period with a grace window, compensating events instead of mutation — and two meters: streaming approximate for the product, batch exact for the invoice.

Pratik Dhanave · ·4 min read

Pricing Models in Code — The Catalog Is Data, Not Constants

Every pricing page looks simple: three tiers, a slider, maybe "contact us." The code behind a pricing page that can evolve is anything but — because pricing changes faster than software, old customers keep old deals, and the moment a price lives as a constant in application code, every experiment becomes a deploy and every grandfathered customer becomes an if-statement. The foundational move of billing engineering is modeling the catalog as versioned data.

Flat, per-seat, graduated vs volume tiers (not the same thing), usage, hybrids — one abstraction: price is versioned data mapping quantity-over-a-period to an amount. Immutable price versions make grandfathering default behavior and invoices re-derivable; application code never holds an amount.

Pratik Dhanave · ·4 min read

Why Billing Is an Engineering Problem

Most teams treat billing as a form you fill in at a payment provider — until the first incident teaches them otherwise. Billing sits at the intersection of money, state machines, and time: it must be exactly right, it changes under regulation and pricing strategy, and every bug is either lost revenue or an angry customer charged twice. This series treats monetization as the engineering discipline it actually is, from pricing models to metering to revenue integrity.

Billing is a correctness-critical, time-dominated system, not a form at a payment provider. The failure modes — public overcharging, silent undercharging, double-charges, price drift — demand financial-grade engineering, and the AI era raises the stakes: usage-based pricing makes metering and entitlements load-bearing. Opens an 8-post series.

All posts on this site are written by Pratik Dhanave, an Agentic AI Architect with 7+ years building production distributed systems, multi-agent AI platforms, and cloud-native infrastructure. About the author → Each article includes working code, architecture diagrams, and references to the specific frameworks and standards discussed. Browse the blog or explore related topics using the tag cloud above.