affiliate.ts
Affiliate program, commission, and settlement rules.
config/affiliate.ts configures whether the affiliate program is enabled, settlement intervals, payout methods, and plan commissions. Product and plan IDs in plans come from products.ts and are not fixed fields. Plans omitted from plans do not generate affiliate commissions.
enabled
Prop
Type
payoutInterval
Prop
Type
payout
Prop
Type
plans
The type of plans is derived from the products and plans in products.ts. Top-level keys are product IDs, and second-level keys are plan IDs within those products. Your project defines both levels of keys, and entries at either level can be omitted.
type Plans = {
[ProductId in keyof Products]?: {
[PlanId in keyof Products[ProductId]['plans']]?: AffiliatePlanConfig;
};
};Plan commission rules
Each configured plan requires commission. Subscription plans also require subscriptionPaymentLimit. One-time purchases must not include this field and can generate at most one commission.
commission
commission can be a percentage or a fixed amount. Choose only one of these two structures.
Percentage commissions
Prop
Type
Fixed commissions
Prop
Type
subscriptionPaymentLimit
Prop
Type
Template defaults
saavo_starter and license are the product and plan IDs used in the template's default configuration. You can change them along with products.ts. They are not fixed properties of affiliate.ts.
| Product ID | Plan ID | Commission type | Rate | Calculation basis | Successful payment limit |
|---|---|---|---|---|---|
saavo_starter | license | percentage | 2000 basis points (20%) | net_subtotal | 1 |
The source comments show two more examples: changing license.commission to a fixed USD 5.00 commission, or first defining a monthly plan in products.ts and then setting its commission rate to 15% with a limit of 3 successful payments. Commented-out configuration has no effect.
Rule changes do not recalculate past commissions
Existing commission records retain their original calculated amounts. When a payment's status changes, the system reevaluates whether that payment exceeds the payment limit, using the updated configuration and payment order.