Skip to content

Affiliates & payouts

Paylera’s affiliates module attributes referred customers to an affiliate, accrues commissions on the customer’s payments, and pays them out in batches with configurable hold periods.

The model

Affiliate ── earns ──► Commission ── batched ──► Payout ── settled ──► Provider
via
  • Affiliate — the entity earning commission. Has a payout method (bank account, PayPal, wallet credit).
  • Commission — accrued for each qualifying customer payment, per a programme’s rules.
  • Payout batch — periodic aggregation of an affiliate’s ready-to-pay commissions, paid in one transfer.

Programmes

A programme defines the commission rule and which products it applies to:

POST /v1/affiliates/programmes
{
"code": "saas-30",
"rule": {
"type": "percent",
"rate": "30.0",
"applies_to": { "product_codes": ["pro", "business"] },
"duration": "first_year"
},
"hold_period_days": 30,
"min_payout_amount": "50.00",
"currency": "USD"
}
FieldMeaning
rule.typepercent or fixed.
rule.ratePercent (0–100) or money amount.
rule.durationfirst_payment, first_year, lifetime.
hold_period_daysDays a commission stays pending before it’s eligible for payout (chargeback / refund window).
min_payout_amountBelow this, batches are deferred to the next cycle.

Attribution

Three attribution methods, picked per programme:

MethodHow it links a customer to an affiliate
codeCustomer is created with referral_code: "alice" matching an affiliate’s code.
cookieHosted-checkout sets a first-party cookie at the click; resolved at customer creation.
apiYour application calls POST /v1/affiliates/attribute explicitly.

A customer can have at most one affiliate; once attributed, the link is permanent unless an operator overrides it (audited).

Commission lifecycle

accrued ──► pending ──► eligible ──► paid
└──► reversed (on refund / chargeback)
StateMeaning
accruedCreated at the moment the customer’s payment succeeded.
pendingWithin the hold period.
eligibleHold period elapsed; ready for the next payout batch.
paidIncluded in a settled payout batch.
reversedThe originating payment was refunded or charged back; the commission is debited.

A reversal during the hold period silently cancels the commission. After payout, a reversal creates a debit against the next batch.

Payout batches

A scheduled worker runs nightly:

  1. Finds every affiliate with eligible commissions ≥ min_payout_amount.
  2. Aggregates them into a payout_batch.
  3. Initiates the transfer through the affiliate’s payout method.
  4. Marks the batch and underlying commissions paid on success.

Manual trigger:

POST /v1/payouts/batches/run
{ "as_of": "2026-05-31T23:59:59Z", "affiliate_ids": ["aff_…"] }

Commission ledger

Every accrued commission posts to the ledger as a liability:

Affiliate cost (expense) 30.00 debit
Affiliate payable (liability) 30.00 credit

When the payout settles:

Affiliate payable 30.00 debit
Cash 30.00 credit

Reversals reverse the posting. The liability balance always reconciles to the sum of pending + eligible commissions per affiliate.

Payout methods

MethodNotes
bankACH (US), SEPA (EU), Faster Payments (UK). 1–3 business days.
paypalSame-day in supported countries.
wallet_creditCredits the affiliate’s customer wallet. Same-instant.
manualWe mark the commission paid; you settle out-of-band. Useful for crypto or rare rails.

Webhook events

EventWhen
commission.accruedA qualifying payment produced a commission.
commission.eligibleHold period elapsed.
commission.reversedThe originating payment was refunded / charged back.
payout_batch.createdA batch was assembled.
payout_batch.settledAll transfers in the batch succeeded.
payout_batch.failedA transfer failed; the batch needs operator attention.

Common pitfalls

  • duration: lifetime on a percent rule with a high rate is a great way to lose money on a long-tail customer. Model the LTV first.
  • Cookie attribution is fragile. If you have an account creation flow, prefer code (let users enter the referral code at signup) or api (set it explicitly when you create the customer).
  • Hold period < refund window = paying for refunded sales. Set hold_period_days ≥ 30 for card-based payments.