LOADING…
0%
Complete changelog

Commit

Fix refunds wrongly draining platform balance for Stripe Connect sales

Commit details

Commit notes

completePurchase credits earnings two ways: Stripe Connect sales pay the seller directly and only bump totalEarnings/totalSales (recordCreatorSaleInTx), while platform-balance sales also credit availableBalanceCents (creditCreatorEarningsInTx). processRefund, however, always deducted availableBalanceCents — so refunding a Connect sale drained balance the creator earned from other, non-refunded platform-balance sales (only floored at 0 by GREATEST, masking the corruption).

The purchase row carried no record of which crediting path was used, so the refund couldn't mirror it.

- Add purchases.paid_via_connect (boolean, default false) + migration 0022. - Set it in completePurchase's atomic completion update (authoritative point, same value used for crediting), keeping credit and refund symmetric. - processRefund now deducts availableBalanceCents only when !paidViaConnect; totalEarnings/totalSales still decrement for every refund.

Default false preserves prior behavior for historical rows (whose path is unknown), so no regression on existing data.

[private session redacted]

Files changed
5
Lines added
+6,657
Lines removed
−3
This page is a permanent record of commit bd99294f.