Integration guides
Platform-specific setup. Every path ends in the same verified-conversion pipeline.
Shopify (beta)
- In Affllux, Integrations → E-commerce → Connect Shopify. Copy the webhook URL.
- In Shopify admin, Settings → Notifications → Webhooks, create JSON webhooks for Order payment (
orders/paid), Refund create (refunds/create) and Order cancellation (orders/cancelled) pointing at that URL. - Copy the signing key Shopify displays and save it with Set signing secret. Requests with an invalid
X-Shopify-Hmac-Sha256are rejected. - Add the SDK to your theme and pass the click id as a cart attribute named
aff_cid:
<script>
(function () {
var cid = (document.cookie.match(/(?:^|;\s*)_aff_cid=([^;]+)/) || [])[1];
if (cid) fetch("/cart/update.js", { method: "POST", headers: { "Content-Type": "application/json" },
body: JSON.stringify({ attributes: { aff_cid: decodeURIComponent(cid) } }) });
})();
</script>Discount codes are used as coupon codes; line items, tax, shipping and discounts are mapped in minor units.
WooCommerce webhooks (beta)
Connect WooCommerce in Affllux to get a webhook URL and a generated secret. In WooCommerce → Settings → Advanced → Webhooks add Order created and Order updated (API v3) with that URL and secret. Orders in processing or completed become purchases, refunds listed on the order reverse commission, and cancelled orders cancel it. The click id is read from the order meta _aff_cid, which the Affllux plugin writes.
WordPress plugin (beta)
The plugin in integrations/wordpress/afflux-tracking adds the SDK to your site, stores _aff_cid on WooCommerce orders and reports paid orders, refunds and cancellations through the REST API with idempotency keys. It is written against documented WordPress hooks but is not covered by this project's automated tests — try it on a staging site with a test key first. Use either the plugin's API reporting or WooCommerce webhooks for purchases, not both.
Stripe (beta)
For merchants selling through Stripe Checkout or Billing:
- Connect Stripe in Affllux and copy the webhook URL.
- In the Stripe Dashboard add an endpoint for
checkout.session.completed,invoice.paidandcharge.refunded, then save itswhsec_…signing secret in Affllux. - Pass the click id when creating the session:
const session = await stripe.checkout.sessions.create({
mode: "payment",
line_items,
client_reference_id: req.cookies.get("_aff_cid")?.value, // or metadata: { aff_cid }
success_url, cancel_url,
});Payment-mode sessions are recorded by PaymentIntent id; subscription sessions by their first invoice id with the subscription id, so renewals (invoice.paid with billing_reason=subscription_cycle) and refunds are matched automatically.
Next.js
// app/layout.tsx
import Script from "next/script";
<Script src="https://YOUR-AFFLUX-HOST/sdk/v1.js" data-key="pk_…" strategy="afterInteractive" />// After payment succeeds (Route Handler, Server Action or webhook handler)
await fetch(`${process.env.AFFLUX_URL}/api/v1/conversions`, {
method: "POST",
headers: { Authorization: `Bearer ${process.env.AFFLUX_SECRET_KEY}`, "Content-Type": "application/json", "Idempotency-Key": order.id },
body: JSON.stringify({ type: "purchase", external_id: order.id, amount_minor: order.totalMinor, currency: order.currency,
click_id: (await cookies()).get("_aff_cid")?.value, customer_id: order.customerId }),
});React single-page apps
Include the script tag in index.html, then call window.Affllux?.pageview() after client-side route changes if you enabled page-view analytics. Conversions must still be sent from your backend.
Laravel
use Illuminate\Support\Facades\Http;
Http::withToken(config('services.afflux.secret'))
->withHeaders(['Idempotency-Key' => 'order-'.$order->id])
->post(config('services.afflux.url').'/api/v1/conversions', [
'type' => 'purchase',
'external_id' => (string) $order->id,
'amount_minor' => $order->total_cents,
'currency' => $order->currency,
'click_id' => $request->cookie('_aff_cid'),
'customer_id' => (string) $order->user_id,
])->throw();Exclude _aff_cid from Laravel's cookie encryption (EncryptCookies::$except), because the SDK writes it in plain text.
Plain PHP and custom sites
$ch = curl_init('https://YOUR-AFFLUX-HOST/api/v1/conversions');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer '.getenv('AFFLUX_SECRET_KEY'), 'Content-Type: application/json', 'Idempotency-Key: order-'.$orderId],
CURLOPT_POSTFIELDS => json_encode(['type' => 'purchase', 'external_id' => (string) $orderId, 'amount' => '149.00', 'currency' => 'EUR', 'click_id' => $_COOKIE['_aff_cid'] ?? null]),
]);
$response = json_decode(curl_exec($ch), true);import os, requests
requests.post(f"{os.environ['AFFLUX_URL']}/api/v1/conversions",
headers={"Authorization": f"Bearer {os.environ['AFFLUX_SECRET_KEY']}", "Idempotency-Key": order_id},
json={"type": "purchase", "external_id": order_id, "amount": "149.00", "currency": "EUR", "click_id": click_id},
timeout=10).raise_for_status()Booking systems, lead forms and mobile apps
Use the conversion type that matches your business: booking, lead, registration, subscription_start/subscription_renewal or custom. Leads and registrations may omit the amount when the program pays a fixed reward. For mobile apps, capture aff_cid from the deep link or landing page, store it with the user on your server, and send conversions from the server — never embed secret keys in an app.
Wix and Webflow
Paste the script tag into the site's custom code (head). Send conversions from the payment provider's webhook handler or your automation tool using the REST API. Native Wix and Webflow apps are planned and not available yet.
PayPal
Native PayPal webhooks are planned. Until then, call /api/v1/conversions from your PayPal order-capture handler.
Payout providers
Affllux records payouts; it does not move money. Pay affiliates through your bank, PayPal or Wise, then mark the payout as paid with a reference. Provider-executed payouts (Stripe Connect, PayPal Payouts, Wise) are planned.