The problem with traditional billing
Most billing systems assume changes happen in the future. You schedule a plan change for next month. You add an add-on starting tomorrow. Everything flows forward in time. But real business doesn’t work that way:- A sales rep closes a deal on Monday but the contract was signed Friday
- A customer calls to complain and you need to backdate a discount
- You discover a pricing error from two weeks ago that affected 50 customers
- An enterprise contract requires a commitment that should have started last quarter
Principles for safe subscription management
Orb’s architecture is grounded in two core principles:-
Explicit timing for all actions
- Every action—whether it’s a usage event, subscription edit, or cancellation—is attached to an explicit timestamp, not just the “current time.”
- This prevents subtle errors, especially around billing period boundaries. For example, canceling a subscription at the end of the month should not risk overcharging a customer just because the request crossed a midnight boundary.
- With Orb, you always control the effective time of every action, ensuring outcomes match your intent.
-
Reversibility and backdating
- All actions are reversible whenever possible. You can undo a scheduled cancellation, extend a trial, or change a contract ramp at any time—unless there are end-user-facing side effects (like a sent invoice or email), in which case Orb issues credit notes to correct the record.
- Orb is built to support backdated actions: the system “rewinds time” as if the action happened at the specified date, then automatically plays forward the consequences to catch up to the present.
How the diff engine works
When you make any change to a subscription—add a price, apply a discount, backdate a cancellation—Orb doesn’t directly manipulate invoices. Instead:- Compute expected state: Given the subscription parameters (prices, timing, configuration), what invoices should exist?
- Compare to actual state: What invoices currently exist in the database?
- Calculate the diff: What needs to be created, modified, or removed?
- Apply atomically: Create new invoices, void or credit existing ones, update the ledger—all in a single transaction
InvoiceDiff containing:
- Invoices to create (with full line item details)
- Invoices to remove (draft invoices are deleted; issued invoices are voided or refunded)
- Invoices to edit (for in-place modifications to draft invoices)
- Credit notes to issue (for refunding portions of paid invoices)
- Ledger entries to adjust (for prepaid credit rebalancing)
Why this matters: real-world scenarios
Backdated subscription creation
A customer signs a contract on March 15th, but their service started March 1st. You create the subscription with a start date of March 1st. What happens:- Orb computes what invoices should exist for March 1-15
- If usage occurred during that period (events with timestamps in that range), it’s automatically included
- Invoices are created with the correct service periods
- Revenue recognition reflects the actual service dates
Mid-period cancellation with refund
A customer cancels on March 20th, but they paid for the full month upfront. What happens:- Orb computes the expected state: subscription ends March 20th
- The diff shows: existing invoice overstates the service period
- Orb issues a credit note for the unused portion (March 21-31)
- The credit goes to customer balance for future invoices (or refund if configured)
Pricing error affecting multiple customers
You discover that 50 customers were on the wrong plan for the past two weeks. What happens:- You correct each subscription’s pricing (or run a migration)
- For each customer, Orb computes the diff between old and new pricing
- Draft invoices are updated in place
- Issued invoices get credit notes or voids as appropriate
- Revenue reports automatically reflect the corrections
Atomicity enables previews, dry runs, and pending changes
A unique advantage of Orb’s atomic, diff-based architecture is that every change is a pure, replayable calculation. This means:- Previews of any endpoint are possible: Because the system can deterministically simulate the effect of any change without side effects, you can preview the result of any API call—whether it’s a subscription mutation, pricing update, or usage event—before committing it.
- Dry runs: Orb’s dry run feature lets you validate requests and see their impact without making any actual changes. The system computes the outcome as if the change were real, but nothing is persisted.
- Pending changes: With pending changes, you can stage a subscription change, preview its effects (including invoice previews), and only apply it when you’re ready. This is possible because Orb can always calculate the post-change state without mutating the underlying data until you commit.
Versioned plans and safe, scalable migrations
Orb’s architecture also enables first-class support for plan versioning and bulk migrations—capabilities that are difficult in traditional billing systems.- Versioned timelines: Every subscription in Orb is a timeline of price objects, each with a start and (optionally) end date. When a plan changes—such as adding an add-on or rolling out new pricing—a new version is created, and the system tracks the lineage and differences between versions.
- Immutable auditability: Plans themselves are immutable; instead, new versions are layered on, ensuring a clean audit trail for every change. This means you always know exactly how each invoice was generated, and can trace changes over time.
- Atomic invoice regeneration: When a subscription migrates to a new plan version, Orb atomically re-generates the set of invoices that should exist, based on the new timeline. This is the same diff-based mechanism that powers all other changes, ensuring migrations are safe and idempotent.
- Flexible effective dates: Migrations can be scheduled to take effect at any date—immediately, at a specific future date, or aligned to each customer’s next billing cycle. Orb’s primitives allow maximum flexibility, so you can roll out pricing changes exactly when and how you want.
- Immediate, scalable propagation: All migrations are applied immediately to the subscription’s state, regardless of the effective date. This ensures that upcoming invoices always reflect the correct pricing, and previews are accurate. Even for large-scale migrations across millions of subscriptions, Orb guarantees correctness and consistency.
What this guarantees
The diff-based architecture provides concrete guarantees that traditional billing systems cannot match:| Guarantee | How it works |
|---|---|
| No orphaned invoices | Every invoice exists because the subscription state demands it. Change the state, and invoices update automatically. |
| No missing revenue | Usage events are never “lost”—they’re always included in the invoice for their timestamp’s billing period. |
| No double-billing | The diff explicitly handles what to remove. You can’t accidentally create duplicate charges. |
| Audit trail preserved | Voided invoices and credit notes remain in the system. The full history is always available. |
| Atomic consistency | Either all changes apply, or none do. No partial states, no cleanup required. |