DOSSIERSEHPC-STRIPE-BILLING
github.com/east-highpeformance-hongkongAsynchronous Stripe Transaction Reconciliation Ledger
atomic ledger bookkeeping syncs client credit wallets
Published: 2026-06-20 | Project: East High Performance Centre | Discipline: Distributed Systems & High-Throughput State
Author: Nicholas Alexander MacAskill — Founder & CTO, Flocano Labs | Canonical: https://www.nicholasmacaskill.com/dossier/ehpc-stripe-billing
Ledger balance drift
0.00
Verified Invariant
Webhook signature verification time
< 40ms
Verified Invariant
Double-Entry Ledgers and Credit Wallet Synchronization
Credit balances and subscription plans are updated dynamically using transactional database triggers and atomic RPC definitions. The billing engine verifies Stripe payment events against recorded metadata before executing balance increases or subscription mutations.
Database Level Ledger Ingestion
Every billing action writes directly to an immutable ledger log table, which is periodically audited to check for discrepancies:
SQLPRODUCTION RUNTIME
-- atomic credit addition transaction
CREATE OR REPLACE FUNCTION add_credits_to_profile(user_id uuid, credit_amount int, payment_ref text)
RETURNS void AS $$
BEGIN
INSERT INTO public.transactions (user_id, amount, type, reference)
VALUES (user_id, credit_amount, 'credit_purchase', payment_ref);
UPDATE public.profiles
SET credits = credits + credit_amount
WHERE id = user_id;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;