Affiliate Program App Starter · Industry version
A referral program built around orders — coupon attribution, refund handling, creator payouts — generated into code your store owns.
Store referrals happen where links can't follow: a creator says a code on camera, a customer texts a friend, an order comes back for refund after the commission was counted. This starter models orders, codes, and returns as first-class objects, so the program's numbers survive contact with retail reality.
01 · The problem
Ecommerce attribution is messier than a tracked click. Creators drive sales through spoken coupon codes on video and podcasts; customers share screenshots, not URLs. A program that only credits link clicks systematically undercounts your best channels — and partners notice when their known sales don't appear in their dashboard.
Returns are the second gap. Apparel and consumer goods run real refund rates, and a commission paid on a returned order is margin gone twice. Generic tools treat the conversion as final at checkout; a retail-shaped program holds commission through the return window and nets refunds out before money moves.
Third, order economics vary by line. Commission on a full-price hero product and commission on a clearance bundle shouldn't be the same rate, and gift cards shouldn't earn at all. That means the program needs order items and product categories in its schema — not just an order total forwarded from a pixel.
02 · Data model
Everything in the base Affiliate Program starter —
partnersreferral_linksreferralsconversionscommissionspayouts— plus the entities this industry actually runs on:
| table | what it holds |
|---|---|
coupon_codes | Partner-assigned discount codes that attribute orders without a click — the attribution channel for creators, podcasts, and print. |
order_items | Line-level products and amounts per referred order, so commission rates can differ by category and exclude non-commissionable lines. |
returns | Refunds and exchanges against referred orders, netted from pending commission before each payout closes. |
03 · Screens
Every partner carries both tracked links and a coupon code, and either one attributes the order. The customer gets a discount, the partner gets credit, and the mention that happened entirely off the web still lands in your ledger.
Commission on a referred order stays pending until your return window closes. Refunds and exchanges net out automatically, so the payout batch pays on kept revenue — no clawing money back from a creator after the fact.
Rates read order items, not just totals: 15% on full-price apparel, 5% on sale lines, nothing on gift cards. The rules are code in your repository, so a margin-driven change ships the day merchandising asks for it.
04 · In practice
Set a creator up with a vanity code and a link, both tied to the campaign. Orders attribute from either channel; the campaign view shows revenue, units by product, and commission accrued while the video is still climbing.
The month's referred orders age past the return window; refunds net out as they arrive. Close the period and the batch pays each partner on kept revenue, with a statement their side of the ledger already matches.
Existing customers get personal codes worth a discount to the friend and store credit to themselves. The same referral tables run this loop — two-sided rewards are a rule change, not a second system.
Yes — codes are a first-class attribution channel. An order that uses a partner's code attributes to them directly, which is how creator and podcast promotion actually converts. Links still work in parallel, and both feed one ledger.
Commission holds as pending until your return window passes, and refunds or exchanges net out before payout. You define the window; because the logic is your code, categories with different return behavior can hold for different periods.
Yes — referred orders carry line items, and commission rules read them. Full-price, sale, and excluded categories can each carry their own rate, keeping the program aligned with actual margin instead of a flat percentage of the order total.
The program is a standalone app you own, fed by order events from wherever your store runs. A webhook or import job writes referred orders and items into your tables; attribution, holds, and payouts run from there.
Dual7 App Starters
A referral program built around orders — coupon attribution, refund handling, creator payouts — generated into code your store owns. Describe your version to start — the output is a project you own.