How to track affiliate clicks, signups, payments and refunds from any website and any payment gateway.
The Install tab in your company shows the same steps with your own keys already filled in.
A program is one product with its own commission rules, affiliates and reports. One company can run several programs, one per product.
With more than one program, every request must say which program it is for: add data-program="program-slug" to the tracking script, send "program" in API calls, and choose the program when you connect a gateway. A referral in one program never earns in another.
Add this to every page of your website. Your public key is in Company > Settings.
<script async src="https://partners.fimuro.com/t.js" data-key="pk_..."></script>When a visitor arrives with ?ref=CODE (or ?via=, ?aff=), the script records the click and saves two cookies on your domain: pp_ref (referral code) and pp_vid (visitor id). Form fields named pp_ref or pp_vid are filled automatically.
Options: data-domain=".example.com" shares the cookie across subdomains, data-param="partner" adds your own URL parameter. For a company with more than one program, add data-program="program-slug".
| Browser function | What it does |
|---|---|
FimuroPartners.signup(email, userId) | Reports a signup from the browser. It is confirmed when your server or your gateway later sends the same visitor id (pp_vid) or referral code. Without that, the commission waits for your review, because a browser call alone can be faked. |
FimuroPartners.referral() | The referral code, to pass into your checkout |
FimuroPartners.visitor() | The visitor id, to pass into your checkout |
Each affiliate gets a referral code and two kinds of link. Both work the same way.
| Link | Example |
|---|---|
| Direct link to your site | https://yoursite.com/?ref=maya7f2a |
| Short link | https://partners.fimuro.com/r/maya7f2a |
| Short link to one page | https://partners.fimuro.com/r/maya7f2a?to=/pricing |
| With a campaign label | https://yoursite.com/?ref=maya7f2a&sub=youtube |
The short link only sends visitors to pages on the program's own website. The sub label shows in reports, so an affiliate can see which campaign brought each sale. A coupon code can be tied to an affiliate too, and then the sale is credited even without a link.
Send JSON with your secret key: Authorization: Bearer sk_.... Never use the secret key in the browser. Limit: 600 requests per minute. Amounts are what the customer paid, tax included, unless you send a smaller amount yourself.
Call when a user signs up. Every later payment from this user is credited to the affiliate (renewals included).
{
"customer_id": "42", // your user id (or send "email")
"email": "[email protected]",
"ref_code": "maya7f2a", // from the pp_ref cookie
"visitor_id": "a1b2c3...", // from the pp_vid cookie
"coupon": "MAYA20", // optional
"program": "program-slug" // required when your company has more than one program
}Call after every successful payment (first payment and renewals). Repeating the same order_id is safe.
{
"order_id": "TRX-10023", // unique payment id
"amount": 1500,
"currency": "BDT",
"customer_id": "42",
"email": "[email protected]",
"ref_code": "maya7f2a", // optional
"visitor_id": "a1b2c3...", // optional
"coupon": "MAYA20", // optional
"gateway": "eps" // shown in reports
}Response: { "ok": true, "status": "created", "commission": 300, "currency": "BDT" }. Other statuses: exists (already counted), ignored (not a referred customer), rejected (self referral).
{ "order_id": "TRX-10023" } // full refund
{ "order_id": "TRX-10023", "amount": 500, "refund_id": "R-1" } // partial refund, refund_id is requiredBefore payout the commission is cancelled (or reduced). After payout the amount is taken from the affiliate's next payout.
Errors come back as { "ok": false, "error": "..." } with one of these HTTP codes.
| Code | Meaning |
|---|---|
| 400 | Something in the request is missing or wrong. The message says what. |
| 401 | The secret key is missing or not valid |
| 403 | The company is disabled |
| 429 | Too many requests. Wait a minute and try again. |
In Company > Gateways, add the gateway and paste its signing secret. Then put the webhook URL in your gateway. Pass the referral as checkout metadata: pp_ref, pp_vid and optional pp_coupon.
| Gateway | Events | Metadata field |
|---|---|---|
| Stripe | checkout.session.completed, invoice.paid, charge.refunded, charge.dispute.created | metadata / subscription_data.metadata / client_reference_id |
| Dodo Payments | payment.succeeded, refund.succeeded, subscription.active, dispute.opened | metadata |
| Paddle Billing | transaction.completed, adjustment.created, adjustment.updated | custom_data |
| Lemon Squeezy | order_created, order_refunded, subscription_payment_success, subscription_payment_refunded | checkout[custom] |
| Polar | order.paid, order.refunded | metadata |
| Razorpay | payment.captured, refund.processed | notes |
Send a POST to the webhook URL with header X-Signature = hex HMAC-SHA256 of the raw body, using the secret shown in the Gateways tab.
{ "type": "sale", "order_id": "TRX-1", "amount": 29, "currency": "USD", "customer_id": "42", "ref_code": "maya7f2a" }
{ "type": "refund", "order_id": "TRX-1" }
{ "type": "lead", "customer_id": "42", "email": "[email protected]", "visitor_id": "a1b2c3..." }PHP (no Composer needed): FimuroPartners.php. Node.js 18+: fimuro-partners.js.
require 'FimuroPartners.php';
$pp = new FimuroPartners('sk_...', 'https://partners.fimuro.com');
$pp->lead(['customer_id' => $userId, 'email' => $email]); // reads pp_ref / pp_vid cookies
$pp->sale(['order_id' => $trx, 'amount' => 1500, 'currency' => 'BDT', 'customer_id' => $userId]);
$pp->refund(['order_id' => $trx]);customer_id or an email, so renewals and refunds can be matched./api/v1/leads from your server at signup.A purchase by the affiliate through their own link is rejected as a self referral, so use a different email for the buyer.