A SaaS-based company providing recurring billing management as an outsourced service.

This integration method uses Recurly API get the details of the purchased plan and to record a commission with the subscription values.

The integration requires the Recurring Commissions feature for tracking the recurring payments/trial conversions.


Recurly configuration

This integration method uses external "Thank you page" especially PHP one, so if you do not have one, please create it. When you have the site, navigate to Configuration->Plans section of your Recurly admin panel and edit your plans. Towards the bottom of the edit plan screen check the checkbox for Bypass Recurly Confirmation and set Return URL After Success to your thank you page, where Recurly API will be used.
Add this string to each URL:


In case you already have question mark in the link, change the one in above code to ampersand (&) symbol.


Enable API

In Recurly admin panel go to Integrations->API Credentials section enable your API if it is not enabled yet, and get your API key.

Please, download Recurly API library (ideally the PHP one) since you will need it in the next step.
Now, navigate to Integrations->Webhooks and use Configure button to add new Endpoint and point its URL to https://URL_TO_PostAffiliatePro/plugins/Recurly/recurly.php

Finally, enable Recurly plugin in your Plugins section of your Post Affiliate Pro merchant panel.


Integration code

Open your thank you page for editing and paste this code to the file:

if (isset($_GET['account_code']) && $_GET['account_code'] != '' && isset($_GET['plan']) && $_GET['plan'] != '') {
	require 'lib/recurly.php';
	/* https://<your-subdomain> */
	Recurly_Client::$subdomain = 'your-subdomain';
	/* your private API key */
	Recurly_Client::$apiKey = '012345678901234567890123456789ab';	

function papTrack() {
    try {
        $subscriptions = Recurly_SubscriptionList::getForAccount($_GET['account_code']);
    } catch (Recurly_NotFoundError $e) {
        // No subscriptions found for received account - echo $e->getMessage();
	$purchasedSubscription = null;
    foreach ($subscriptions as $subscription) {
        if ($subscription->plan->plan_code != $_GET['plan']) {
        $purchasedSubscription = $subscription;
	if ($purchasedSubscription === null) {
    $subscriptionId = $purchasedSubscription->uuid;
    $subscriptionCode = $purchasedSubscription->plan->plan_code;
    $invoice = $purchasedSubscription->invoice->get();
	$totalCost = $invoice->subtotal_in_cents / 100;
    $currency = $invoice->currency;
	echo '<script id="pap_x2s6df8d" src="https://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>'.PHP_EOL;
	echo "<script type='text/javascript'>
var sale = PostAffTracker.createSale();


Keep in mind you have to upload files from the Recurly API client to the directory where your Thank you page is. As you can see, the third line of the code includes /lib/recurly.php file from the API client.

The next lines define your Recurly subdomain and your API key, so please add your credentials there!

Do not forget to integrate your site with the click tracking code.