Larz โบ Referral program in Python
Referrals & affiliates as a primitive
Growth loops shouldn't be a separate SaaS. Larz gives every user a referral link and pays commissions automatically โ on the same ledger as your marketplace payouts.
pip install larz
import larz.referrals as referrals
referrals.enable(app, reward="20%")
@app.before
def _ref(req): app.referrals.capture(req) # grab ?ref=CODE
# on signup, bind the new user to whoever referred them
app.referrals.attribute(new_subject, req=req)
url = app.referrals.url(req.subject) # their share link
How it pays out
When a referred user makes a payment, Larz credits the referrer's payout ledger with the
reward (a percent like "20%" or a flat "$5"). Track progress with
app.referrals.stats(subject) โ referrals, conversions and earnings โ and settle with
app.money.mark_paid(), exactly like seller payouts.
FAQ
How are commissions paid?
When a referred user pays, the reward (percent or flat) is credited to the referrer's payout ledger; you settle it with app.money.mark_paid().
Does it prevent self-referrals and double-counting?
Yes โ a subject can't refer themselves, each referred user binds to one referrer once, and by default only the first payment is commissioned.