Skip to main content
Use this recipe when you sell subscriptions and want to pay the referring affiliate for every payment, not only the first one. It works with any billing system that tells your server when a payment succeeds. The idea: a customer ties a person in your product to the affiliate who referred them. You create the customer once, when they sign up. After that, every payment you report with the same customer_id goes to that affiliate. Renewals need no click and no cookie.

Before you start

Check three settings in your program.
  • Enable lifetime/recurring commissions is on, in the program’s commission settings. Without it, customer_id alone doesn’t attribute a payment.
  • Recurring frequency cap and Recurring time cap are set the way you want, or left empty for no limit. See Limit how long an affiliate earns.
  • Recurring commissions on the commission type is set to Smart connected. This means renewals come from your integration. The other option, Time based, makes Tapfiliate create renewals itself, see Let Tapfiliate generate renewals.
You can read the first two through the API: Retrieve a program returns recurring, recurring_cap and recurring_period_days.

Steps

1

Create the customer at sign-up

When a visitor who came through an affiliate signs up, create a customer from your server. Capture the affiliate’s click in the browser first, as in step 1 of Track sales from a custom checkout.
No commission is created yet. The response is the customer. Save its id (cu_…) next to your user: you need it to cancel the customer later.
The cookie time is checked here, at sign-up. Payments that come later are not limited by it.If the visitor came without an affiliate, don’t create a customer. You will skip their payments in the next step.
2

Report every successful payment

Each time your billing system confirms a payment of a referred customer, create a conversion with the same customer_id. Send the payment’s ID as external_id and the amount actually charged.
Tapfiliate finds the customer by customer_id and gives the commission to the customer’s affiliate. Other identifiers in the request are ignored. The response is the conversion with its commissions and a customer object.The first conversion moves the customer from trial to paying (from new to active, from lead to won).
3

Cancel the customer when the subscription ends

Use the cu_… ID you saved in step 1. If you don’t have it, find it with GET /customers/?customer_id=USER789.
The response is the customer with status canceled (lost for leads, stopped otherwise). After that, a conversion with this customer_id fails with 400 Customer is capped. No new conversions will be generated for this customer. Existing commissions are not changed.If the person subscribes again, uncancel the customer with PUT on the same URL. The original affiliate keeps earning:
Cancel with DELETE /customers/{id}/status/. DELETE /customers/{id}/ without status/ deletes the customer permanently.

A different rate for the first payment

Tapfiliate doesn’t decide which payment is the first. The commission type you send does. To pay, for example, a fixed amount for the first payment and a percentage of each renewal:
  1. In the program, create two commission types. Give them identifiers, for example first-payment (fixed) and renewal (percentage). Identifiers use lowercase letters, digits and dashes.
  2. Send "commission_type": "first-payment" with the first payment and "commission_type": "renewal" with every later one. Your billing system knows which payment is which.
List program commission types returns the identifiers of a program’s types. An identifier that doesn’t match an active commission type in the program is not an error. The program’s default type is used instead, so check the commissions in the response while you test. Affiliate group overrides still apply to the type you send. To pay only for the first payment, report only the first payment. Turning recurring commissions off doesn’t do it: a later payment sent with another identifier, such as referral_code, still creates a commission.

Limit how long an affiliate earns

Two program settings stop commissions for a customer. Leave them empty for no limit.
  • Recurring frequency cap — the number of conversions per customer. The first payment counts too. Conversions whose commission type has Count recurring commissions towards cap turned off are not counted. Disapproved commissions still count.
  • Recurring time cap — the number of days from the moment the customer was created. With a free trial, the trial is included.
With a frequency cap of 12, the 12th counted conversion is still created, and the customer’s status becomes capped, for example paying_capped. Later conversions fail with 400 Customer is capped. No new conversions will be generated for this customer. Once the time cap has passed, the next conversion fails with 400 Recurring cap or recurring period exceeded for this customer, and the customer becomes capped too. Raising the cap later doesn’t reopen customers who are already capped. To reopen one, uncancel it with PUT /customers/{id}/status/.

Let Tapfiliate generate renewals

If you can’t report each payment, set Recurring commissions on the commission type to Time based and pick a Recurrence interval: weekly, monthly or yearly. You still create the customer and send the first payment with this commission type, as in steps 1 and 2. From then on, Tapfiliate creates a conversion for the customer every interval by itself, until you cancel the customer or a cap is reached. Each generated conversion repeats the amount and the commission type of the first payment. Its external_id starts with autorecur-. Upgrades, downgrades, failed payments and refunds are not reflected, so report payments yourself whenever your billing system can.
Don’t combine the two. Payments you report don’t move the schedule of a Time based commission type, so each renewal would be paid twice: once by your conversion and once by the generated one.

Refunds and corrections

  • Refund of one payment. Disapprove the commission of that payment with Disapprove a commission. Its ID is in commissions[].id of the conversion.
  • Partial refund. Change the conversion’s amount with Update a conversion and ?recalculate_commissions=true.
  • Subscription ended. Cancel the customer, step 3.
On accounts that use Tapfiliate Pay, an approved commission can’t be disapproved: the API answers 409 commission_approved, see Errors.

Customer statuses

The status you choose at creation sets the kind of customer. Statuses then change like this: Uncanceling returns the customer to its active status, to its capped status if the frequency cap is reached, or to its initial status if it has no conversions yet. PUT /customers/{id}/status/ on a customer that is still trial, lead or new fails with 400. Such a customer becomes active only through a conversion.

Common pitfalls

  • Missing tracking parameter value and no customer found for customer id: …. The customer doesn’t exist. It was never created, or the payment uses a different customer_id than the sign-up, for example the billing system’s own customer ID instead of yours. Send the same value in both places.
  • Missing tracking parameter value and no lifetime/recurring commissions enabled in program: …. The customer exists, but Enable lifetime/recurring commissions is off in its program.
  • The same external_id for every payment. The second payment fails with Duplicate conversion. Use the payment or invoice ID, not the subscription ID.
  • A returning customer. A canceled customer stays canceled, even if the person comes back through a new affiliate link. Uncancel it to keep paying the original affiliate.
  • Renewals without customer_id. A renewal sent with only a click, tracking ID or referral code is attributed like any new sale. A click or tracking ID must be within the cookie time, and the commission may go to another affiliate.
  • Turning recurring commissions off. Customers with a Time based schedule are canceled, and customer_id alone stops attributing payments.
More messages and what to do about them are in Errors.