DEV Community

Taocarts跨境
Taocarts跨境

Posted on AI-assisted

How Taocarts Built a Referral Layer That Turns Buyers Into Resellers

How Taocarts Built a Referral Layer That Turns Buyers Into Resellers

A common growth loop in cross-border reselling is simple: a happy buyer becomes a seller. They already trust the supply chain, they know the catalog, and they have their own audience back home. The natural next step is letting them refer others and earn a cut. We built this referral layer into Taocarts, the system that bundles sourcing, forwarding, and warehousing for China-to-overseas resellers. Here is how we designed it without opening a fraud hole.

The model

Each reseller gets a unique referral code. When someone signs up or places their first order using that code, the system attributes the relationship and computes a commission on qualifying orders. The key design decision was to separate "attribution" from "payout": attribution is immediate and cheap; payout is a deliberate, reviewed process.

Why not just trust the code in the URL

The naive version stores the referrer id in a cookie or query param and credits on signup. That breaks the moment someone shares a screenshot of "use my code" in a group chat where the link gets stripped, or when a referred user clears cookies and comes back later. We instead persist a referral_pending record keyed by the new account's email at creation time, with a grace window. If the same email later converts, attribution still lands.

Guarding against self-referral and rings

The obvious abuse is referring yourself through a second account to farm commission. We enforce a one-hop rule: a reseller cannot be referred by someone they have already referred, and an account cannot hold both the referrer and referee roles in the same pair. We also run a periodic check for tight referral rings (A→B→C→A) and flag them for manual review rather than auto-banning, because some legitimate small teams really do cross-refer.

Commission math without floating-point regrets

Money math is done in integer minor units (cents), never floats. A commission rate of 5% on an order of 1999 cents is computed as floor(1999 * 5 / 100) = 99, not 1999 * 0.05. This avoids the classic "why is it off by a penny" reconciliation ticket. We keep the raw rate and the computed amount in the same row so any dispute is auditable.

Payout as a reviewed workflow

Commissions accumulate in a ledger but are not paid automatically. A reseller requests payout; the system snapshots the eligible, non-disputed earnings and creates a payout task. If an order tied to those earnings is refunded within the dispute window, the corresponding commission is reversed before payout finalizes. This prevents paying out on orders that bounced.

Exposing it cleanly

The reseller console, built in React, shows their code, their referred accounts, and a live ledger. The Laravel backend exposes read endpoints that are heavily cached, because this dashboard is read-often, write-rarely.

A referral loop is a force multiplier, but only if attribution is robust and payouts are honest. Build the guardrails first, and the growth takes care of itself.

Top comments (0)