Billing that survives being audited
The webhook endpoint verifies Stripe signatures against the raw request body, and handles completed checkouts, delayed asynchronous payments, refunds and dispute creation as distinct cases rather than one happy path. Credits move through a ledger, not a mutable balance column, so any figure can be explained after the fact. There is a reconciliation command that replays a date range and reports drift. The service also refuses to start if it finds test keys alongside a production configuration — a five-line check that removes an entire category of incident.