Run a referral or affiliate program
Referral trees, commissions and rank progress, with the UI to show them.
The problem
Referral schemes look trivial until the second level. Who gets credit when a referred user refers someone else? What happens to a commission when the underlying payment is refunded? How does a participant see why they were paid what they were paid?
Get the arithmetic wrong and you are not fixing a bug, you are correcting people's money — which is a different kind of problem.
What you are building
Live surfaces, not screenshots — every one composed from the same components you would install.
Downline tree
fancy-mlm-ui renders unilevel, binary and matrix trees from the same JSON.
Commission statement
Reversed rows are struck through and excluded from the paid total.
| Level | Recipient | Tier | Amount | Status |
|---|---|---|---|---|
| 1 | Ken Mbeki | 240.5 | paid | |
| 1 | Priya Raman | 198 | paid | |
| 2 | Tom Alvarez | 64.25 | pending | |
| 2 | Jo Fenwick | 31 | reversed | |
| Total (paid) | 438.5 | |||
The code
// One computation PER REWARD, carrying level, metric and recipient -- that
// record is what a statement is rendered from months later, when somebody asks
// why a specific number is what it is.
$rewards = Mlm::computeRewards($order, [
'levels' => [1 => 0.10, 2 => 0.05],
]);// Refunds land after payout runs. A reversed row that stays visible -- struck
// through and excluded from the paid total -- is the difference between a
// statement someone trusts and one they dispute.
Commission::where('order_id', $order->id)
->where('status', '!=', 'paid')
->update(['status' => 'reversed', 'reversed_at' => now()]);How to solve it
Install the engine
Referral trees with the common structures — unilevel, binary, matrix — and the commission rules that go with them.
Run thisbash composer require particle-academy/fancy-mlmRecord referrals as they happen
Sign-ups attach to the referrer, building the tree as a side effect of registration rather than as a nightly reconciliation.
Show participants their own numbers
Ready surfaces for the downline tree, the commission statement and rank progress — the three things a participant asks for, and the three that generate support tickets when missing.
Run thisbash npm install @particle-academy/fancy-mlm-ui
