The Payment System is a multi-party revenue distribution platform that handles the full lifecycle of payments in the Zooly marketplace. It manages payments from buyers, distributes revenue among multiple stakeholders (talent, agents, platform, Stripe fees, ambassadors, host partners), and processes payouts to talent accounts.
Creates Stripe PaymentIntents by fetching product data (source of truth for price and seller), and tracks checkout state from initiation through completion.
Atomically marks intents as completed, creates payment records, and generates share tracking records for all stakeholders.
Splits each payment among stakeholders:
Holds earned shares until threshold ($100 default), then transfers via Stripe Connect to talent accounts.
Pre-pays talent and automatically offsets against future earnings.
Creates negative records, cancels originals, and adjusts advance balances when refunds occur.
The client endpoint (POST /api/payments/complete) actively completes payments by querying the Stripe API to verify charge status, then calling the completion engine. The Stripe webhook (charge.succeeded) serves as a fallback for cases where the client never calls the endpoint (e.g., user closes the browser). Both paths call the same idempotent completePayment() function with FOR UPDATE row locking, so only one succeeds.
Structured payment event logging with component tagging for debugging and compliance.
All monetary amounts are in integer cents, not dollars. Every variable, parameter, column, and API field that represents money must use the Cent suffix to make the unit unambiguous (e.g. amountCent, platformFeeCent, totalBrandPriceCent). Never store or pass currency as floating-point dollars in the payment system.
accountId (not userId)zooly_acc, stripe_acc) for platform and fee trackingCheckout Initiation → Payment Intent Created → Stripe Processing →
Client Completes (or Webhook Fallback) → Payment Completed → Share Tracking Created →
Payout Accumulation → Threshold Reached → Payout Processed
On This Page
What is the Payment System?Key FeaturesSystem Components1. Payment Processing Pipeline2. Payment Completion Engine3. Revenue Distribution System4. Payout Accumulation & Processing5. Advance Payout Mechanism6. Refund Reversal Engine7. Dual-Path Payment Completion8. Audit LoggingCurrency ConventionArchitecture HighlightsPayment LifecycleNext Steps