The hardest part of this build was Stripe integration flexibility. A marketplace payment system is not a single checkout flow. It is a web of scenarios that branch depending on timing, user action, and asynchronous webhook events.
The platform had to handle normal payments, expired checkouts, pre-payout cancellations, post-payout refunds requiring transfer reversals, failed refunds with retry logic, payout failures, disputes, and duplicate webhook deliveries. Each scenario needed its own state-transition path, and all of them had to leave the deal record in a valid, recoverable state regardless of the order events arrived.
Getting Stripe right meant building idempotent operations, replay-safe webhook processing, deal-specific idempotency keys, separate webhook signature verification for platform and connected-account events, and a cancellation pipeline that distinguishes between unpaid expirations, paid refunds, and completed deals requiring transfer reversal before refund.
Those paths are covered by the test suite: cross-tenant isolation, webhook signature rejection, duplicate checkout prevention, retry safety, refund flows, transfer reversals, and direct state-mutation denial.