Urgent.News

One page, thousands of outlets. See who else covered it.

Editions

Tech

Never split the money on payment success

Here's a line of code that looks completely reasonable: the moment a buyer's card is charged, credit the vendor's share to their payout balance. It's the obvious anchor — paid_at is already a timestamp sitting right there on the order, the money genuinely did just arrive, and "bill the vendor when we got paid" reads like the simplest possible rule. It is also, in a marketplace with real buyers…

The article discusses the importance of a particular coding decision in a payment settlement system for a multi-vendor platform. The author argues that paying vendors immediately upon receiving payment from buyers, using the "paid_at" anchor, can lead to significant problems when refunds are required. This is because once the money is committed to the vendor, reversing a refund becomes a complex accounting and collections issue involving multiple parties, rather than a straightforward database operation.

The author instead proposes using a "delivered_at + RETURN_WINDOW" anchor, where vendors are only billed after the order has been delivered and the return window has closed. This approach avoids turning every post-payment refund into a collections problem, as the money remains held by the platform until all conditions for billing are met.

When a refund is requested within the return window, the system simply marks the order as excluded from the billing process. The vendor still gets paid at the scheduled time, but the refunded amount is effectively never recorded in the billing system, preventing the need for any debt reversal. This design ensures that refunds are handled as a prevention of debt creation, rather than an attempt to recover previously accrued debt.

The author concludes that while this approach delays vendor payouts by the length of the return window, it eliminates the complex accounting and collections challenges that come with the "paid_at" anchor. The key takeaway is that treating refunds as a way to prevent debt from ever being incurred, rather than a way to recover debt that has already been recorded, leads to a more robust and less expensive payment settlement system.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Wednesday 19 August →