This integration method uses Recurly API to identify last payment of the customer and to record a commission based on that.


Recurly configuration

This integration method uses "Thank you page" especially PHP one, so if you do not have one, please create it. When you have the site, navigate to Configuration> Subscription Plans section and edit your subscriptions. 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 Developer> API credentials section enable your API if it is not enabled yet, and get your API key.

Please, download Recurly API files as you will need it in the next step.
Now, navigate to Developer> Push Notifications and use Configure button to set Push Notification URL to point to http://URL_TO_PostAffiliatePro/plugins/Recurly/recurly.php

Finally, enable Recurly plugin in your Plugins section in merchant panel.


Integration code

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

if (!empty($_GET['account_code'])) {

Recurly_Client::$apiKey = '12345678912345678912345678912345'; // set your API key here

$invoices = Recurly_InvoiceList::getForAccount($_GET['account_code']);

foreach ($invoices as $invoice) {
  $inv = explode(", ","{$invoice}");
  foreach ($inv as $key=>$value){
    $res = explode("=",$value);
    if ($res[0] == "invoice_number")
    if ($res[0] == "subtotal_in_cents")

<script id="pap_x2s6df8d" src="http://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">

var sale = PostAffTracker.createSale();
sale.setTotalCost('<?php echo $total;?>');
sale.setOrderID('<?php echo $_GET['account_code'];?>');
sale.setProductID('<?php echo $_GET['plan'];?>');
sale.setData1('<?php echo $orderID;?>');


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

The second line defines your API key, so please change it!

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