PayPal Express Checkout (IPN and custom field used by other script)

The faster, safer way to send money, make an online payment, receive money or set up a merchant account.

PayPal Express Checkout integrates using IPN callback even if the callback and customfield is used by other system (e.g. shopping cart). Because of this youwill have to choose separator which will separate our and 3rd partycookie value. We will use || in this example.

Note! This is description of integration with PayPal if you use PayPalbuttons on your web pages. If you use PayPal as a processing system inyour shopping cart, use the method for integrating with shopping cart,not these steps.


Choose separator

Choose separator which will separateour and 3rd party cookie value. We will use || in this example. Youhave to configure Paypal plugin to use this separator. Go to Plugins-> Paypal -> Configure -> Custom Value Separator


Paypal button

Now add the following code into EVERY PayPal button form. Please make sure that the custom field you have in your button has id="pap_ab78y5t4a".

<script id="pap_x2s6df8d" src="http://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">PostAffTracker.setAccountId('Account_ID');

This will ensure that referrer will be added to the custom field after the specified separator.


Integration with your IPN processing script - part 1

Now the IPN callback is pointed to your script. This callback has to beforwarded also to PAP paypal.php script, which url is case, your paypal processing script is in PHP, you can use followingcode to accomplish that. You can place it at the beginning of yourprocessing file.

/* 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);
/* end of PAP integration */


Integration with your IPN processing script - part 2

The custom parameter is in format 3rdPartySystemValue||PapValue. Inorder for 3rd party system to work correctly you need to parse3rdPartySystemValue from the custom parameter. To do this add followingcode right after PayPal IPN verification.

$separator = '||';
    if ($_POST['custom'] != '') {
      $explodedCustomValue = explode($separator, $_POST['custom'], 2);
          if (count($explodedCustomValue) == 2) {
            $_REQUEST['custom'] = $_POST['custom'] = $explodedCustomValue[0];

This is all that is required. Now whenever there's sale, PayPal Express Checkout willuse its IPN function to call our sale tracking script, and system willgenerate commission for the affiliate.