This integration method is for aMember versions lower than v4.

Integration with aMember uses a variation of General solution, it tracks sales by invoking hidden script from "thank you" page.

1.

Integration

Put the following code to the aMember thanks.html page

<script id="pap_x2s6df8d" src="http://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">PostAffTracker.setAccountId('Account_ID');
var sale = PostAffTracker.createSale();
sale.setTotalCost('{$payment.amount}');
sale.setOrderID('{$payment.payment_id}');
sale.setProductID('{$payment.product_id}');

PostAffTracker.register();
</script>

2.

Integration of recurring sales with PayPal

If you want to integrate aMember with PayPal recurring payments then follow these instructions. You will have to find the paypal_r.inc.php on your server /amember/plugins/payment/paypal_r

Insert next code right after this line:
function paypal_validate_ipn($vars){

/* PAP integration */
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, "http://URL_TO_PostAffiliatePro/plugins/PayPal/paypal.php");
 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
 curl_exec($ch);
/* end of PAP integration */

Now find this line (2x times):      'custom'      => '', 
and change them to:                   'custom'      => $_COOKIE['PAPCookie_Sale'],

In case of version 4.4.x the variable is $_COOKIE['PAPVisitorId']

Notice, that your cookies must be available at the domain where amember in order to track sales.

3.

Signup form integration

It's possible to integrate Amember in way, that every new user signup will create also affiliate account in your PAP in the same time. This integration is using our API, therefore it's necessary to upload PapApi.class.php into your Amember main folder. Then locate file signup.php (also in the main folder), open it in some text editor and add following code right after this line:

proceed_to_payment($payment_id, $member_id_exists);

require("PapApi.class.php");
          try {
                $session = new Gpf_Api_Session("http://URL_TO_PostAffiliatePro/scripts/server.php");
                if(!$session->login("merchant_username", "merchant_password")) {
                    return;
                }
                $affiliate = new Pap_Api_Affiliate($session);
                $affiliate->setUsername($_POST['email']);
                $affiliate->setRefid($_POST['login']);
                $affiliate->setPassword($_POST['pass0']);
                $affiliate->setFirstname($_POST['name_f']);
                $affiliate->setLastname($_POST['name_l']);
                if(!$affiliate->add()) {
                    //echo "Cannot save affiliate: ".$affiliate->getMessage();
                    return;
                } else {
                    // affiliate was successfully added
                }
            } catch(Exception $e) {
                //echo "Error while communicating with PAP: ".$e->getMessage();
                return;
            }


This is all that is required. Now whenever there's sale, aMember willcall our sale tracking script, and system will generate commission forthe affiliate.