Production Blueprint · Updated November 2026
Automating multi-party payouts and catching Stripe webhook drift
Paying contractors, technicians, or referral partners by hand from exported CSVs breaks down fast as volume grows. For Therapy Animal Hub, we built an automated daily payout runner and an independent read-only drift monitor that verifies our database against live Stripe charges.
The problem
Therapy Animal Hub pays state-licensed clinicians daily as they complete client evaluations and pays multi-tier affiliates monthly based on tracked promo codes. Calculating who earned what across hundreds of orders, refunds, and sub-affiliate tiers in spreadsheets burns hours every week and invites costly payout mistakes.
Even after automating payouts, relying solely on webhooks leaves a blind spot: if someone issues a refund from the Stripe dashboard and a webhook drops, reporting and payout balances quietly diverge.
The production architecture we run
- Dry-run by default with distributed locking: the payout job acquires a timed database lock, calculates eligible provider and affiliate payouts in integer cents, and logs structured JSON stats. Transfers only execute when run with an explicit live-key guard and execution flag.
- Built-in clearance windows: provider payouts wait 2 days and affiliate payouts wait 7 days after charge settlement, catching early cancellations before cash leaves the account.
- Read-only Stripe drift monitor: a separate scheduled cron job samples the most recent 100 charges in our database, retrieves the live records from Stripe (throttled cleanly under API limits), and alerts immediately if any refunded amount or reporting mirror falls out of sync.
- Automated Postgres reporting mirror: operational SQLite/Turso data syncs incrementally into Postgres with freshness checks so finance and operations always query accurate numbers.
How this translates to Utah trades and distribution
Home services companies calculating technician commissions and spiffs, or distributors reconciling sales rep commissions against QuickBooks invoices and credit memos, face the exact same math. UtahDevCo builds these reconciliation pipelines under our $0-down audit and 50% Year-1 savings model.
Frequently asked questions
Why do payment webhooks drift out of sync with internal databases?
Staff often issue refunds, adjustments, or partial credits directly inside the Stripe or payment processor dashboard. If a webhook fails or times out, your internal database still shows the original paid amount, creating silent accounting discrepancies at month end.
How do you prevent an automated payout script from double-paying someone?
We combine a database-backed distributed lock (with a TTL), dry-run-by-default execution requiring an explicit --execute flag, clearance delay windows (such as 2 days for service providers and 7 days for affiliates), and charge-level checks before any transfer fires.
Still reconciling payouts or commissions in Excel?
Book a free audit and we will calculate how many office hours you can eliminate in Year 1.