
The challenge
Processing money securely with idempotent split payments and reliable multi-vendor payouts.
The solution
Idempotent webhook handlers, a ledger-based payments model and queued payouts with automatic retries.
Outcome
- $2M+
- processed
- 300+
- vendors
- 0
- double-charges
Key decisions
- $2M+ processed with zero double-charges
- 300+ active vendors with automated payouts
- Idempotent webhook processing
- Double-entry ledger for financial accuracy
Code highlights
Idempotent webhook
if (await seen(event.id)) return ok();
await recordLedger(event);Checking event id first makes webhook handling idempotent.
Ledger entry
DB::transaction(fn() => Ledger::post($debit, $credit));A double-entry ledger inside a transaction guarantees correctness.