Refer a friend: you get 1,000 credits when they first pay for Pro or Team; they get 20% off for 3 months.Turn customers into a sales channel. A referral program gives a reward to a customer who brings a new one (the referrer), and optionally one to the new customer (the referee). Ledger makes each referrer’s code, checks every redemption, waits for the trigger you choose, checks the cards in Stripe, and pays out both sides. Each reward is a reward from your catalog: a coupon that takes money off, or a grant of credits or units.
The catalog
AddreferralPrograms to your catalog beside the rewards they name, or write one with POST /v1/referral-programs:
ledger.catalog.json
A catalog without
referralPrograms leaves your programs as they are; one with it states all of them, and a program left out is archived. A change to a program applies to referrals from then on; referrals already rewarded keep what they got.
Give each referrer a code
Get a customer’s referral code returns the referrer’s code in a program: made on the first call, the same one on every call after. Show it on their account page or in a share link.Redeem a referral code
The new customer types the code where they’d type a promotion code, and your app sends it toPOST /v1/customers/redemptions, the same route as any promotion code:
referral: rewarded at once for a signup program, pending until the trigger for first_payment. When the program gives the new customer a reward at redeem, the reply also carries their redemption.
What each side gets, and when
A coupon goes on the bill like any discount, and a grant joins the customer’s balance and sends
credits.granted.
The trigger
Withfirst_payment, a referral pays out once it has turned into revenue: the new customer’s first invoice with money paid for a covered plan. Ledger records the trigger in the same transaction as the payment, from every path that pays for a plan: a first invoice, a lifetime plan, a converted trial, a renewal or an upgrade. A free plan, a trial’s $0 invoice or a 100%-off first month waits for the first invoice with money on it.
The referral worker then pays it out within seconds:
- It reads the cards saved on both customers in Stripe. If the new customer has a card the referrer has saved (the same card fingerprint), the referral is
refusedwithsame_payment_method. - If the referrer already has
maxRewardsPerReferrerrewards, it’srefusedwithreferrer_limit_reached. - Otherwise it’s
rewarded: both rewards are given and areferral.rewardedwebhook is sent.
Fraud checks
Ledger refuses a referral code for:- the referrer themselves, or a customer on the same Stripe customer (
422 self_referral); - a customer already referred in this program (
409 already_referred); - a customer who has paid for a plan or credit pack (
409 referee_not_new), so referral rewards go to genuinely new customers; - with
signup, a referrer who already hasmaxRewardsPerReferrerrewards (409 referrer_limit_reached).
See a customer’s referrals
List a customer’s referrals returns theircodes, the customers they referred (asReferrer, newest first), and who referred them (asReferee), each with its status and refusedReason.
Routes
Webhooks
Rules
- A program’s rewards are active rewards of the environment (
unknown_reward). - Archive a program before archiving a reward it gives (
409 reward_in_use). Archiving a program stops new codes and redemptions; referrals already made keep their rewards. - Each customer is referred once per program, and only before they’ve paid for a plan or credit pack.
- A refund of the new customer’s payment leaves the referrer’s reward in place.