Skip to main content

Billing, Metering, and Payments Service implemented

This page is the detailed engineering packet for the money-domain shared services.

Scope

The shared money domain owns:

  • usage ingestion and attribution
  • rating inputs and pricing context
  • immutable ledger entries
  • balances and billing posture
  • checkout sessions, webhooks, refunds, and provider reconciliation

It should not be reimplemented inside each product.

Control Model

Main Invariants

InvariantWhy it matters
ledger is append-onlymoney truth must not be rewritten
balances are derived, not directly mutatedprevents hidden financial drift
attribution includes organization / department / projectone shared billing model across products
payment reconciliation is auditableprovider custody must remain reviewable

Attribution Shape

Billing should preserve:

  • organization id
  • department id
  • project id
  • billing account id
  • actor / service account id
  • product id
  • resource type and resource id
  • usage unit and quantity
  • pricing snapshot

Main Contract Surfaces

SurfacePurpose
usage ingest API/eventsrecord billable usage inputs
billing read modelsshow balance, usage, financial posture
payment session APIscheckout/initiation path
webhook workerprovider event handling and reconciliation
finance recovery / audit surfacesoperator-safe money correction path

Failure / Recovery Model

Failure classExpected posture
usage ingest delayedbuffer durably and surface lag
payment webhook delayedretry durably
ledger writer unhealthyfail safely; never silently skip writes
stale balance readshow freshness / posture explicitly

Security / Audit Expectations

  • no direct ledger mutation
  • all privileged finance actions audited
  • payment custody and refund paths are evidence-bearing workflows
  • repeated direct SQL checks indicate missing operator read surfaces