Table of Content >> Advanced Features >> Integration with Paypal IPN

Integrating PayPal's IPN with AffiliateShop

If your merchant site is currently using PayPal as it's shopping cart, you can integrate PayPal's Instant Payment Notification system with AffiliateShop's Transaction API to perform commission tracking.

Please read up AffiliateShop's features of FlexiLink and Transaction API before proceeding.

Warning: Implementing IPN Sale Tracking, although ideal, involves a substantial coding effort. You must be mentally prepared before embarking on this endeavour.

Step 1: Use FlexiLink to direct your affiliates' customers.

  1. Use flexilink urls in your banners or urls links for your affiliates, e.g., http://www.mydomain.com/index.php?AID=123456&BID=123.
    * Note: mydomain.com, 123, and 123456 are just sample values. BID is the banner id, if applicable.

  2. This index.php should contain the AffiliateShop FlexiLink url tracking.
    <img src="http://edge.affiliateshop.com/public/FlexiLink?AID=123456&BID=123" width=1 height=1>.

    The AID and BID values in the FlexiLink url should be generated by index.php, derived from the HTTP URL string.

  3. This index.php should also create a cookie with the value as the Affiliate AID passed in through the url.

    You may need to contact your web site developer to help you to create the code that stores a cookie on the visitor's computer. For most programming languages, this is a very simple task. You can also contact us if you need assistance. There is a one time programming assistance fee of US$50.00.

Step 2: Edit all PayPal order button page.

  1. Insert the AID value from the cookie created in Step 1.3 into all your PayPal Shopping cart buttons.

    <!-- Begin PayPal Logo -->
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="webmaster@mydomain.com">
    <input type="hidden" name="undefined_quantity" value="1">
    .
    .
    <input type="hidden" name="custom" value="#####AIDCookieValue#####">
    .
    .
    <input type="hidden" name="amount" value="4.99">
    <input type="hidden" name="return" value="http://www.mydomain.com/thanks.html">
    <input type="hidden" name="cancel_return" value="http://www.mydomain.com/canceled.html">
    <input type="image" border="0" name="submit" src="http://images.paypal.com/images/x-click-but5.gif" alt="Make payments with PayPal - it's fast, free and secure!">
    </form>
    <!-- End PayPal Logo -->

  2. Make sure the '#####AIDCookieValue##### is replaced by your app with the AID value from the cookie created in Step 1.3.

Step 3: Activate IPN in you PayPal account.

  1. Login to your Business or Premier PayPal Account.

  2. Click Profile subtab.

  3. Under Selling Preferences, click Instant Payment Notification Preferences.

  4. Click Edit.

  5. Click the checkbox and enter the URL of your application (http://www.mydomain.com/process.php, for e.g.) that will process the IPN posts.

  6. Click Save.

Step 4: Create your script to process the IPN post.

  1. From Step 3.5, PayPal will post to your url after a successful payment. You need to create the appropriate scripts to handle the parameters from that post.

  2. For e.g., process.php will receive the post and perform processing. Please refer to PayPal offering code samples for handling IPN in your site.

Step 5: Have your script post to AffiliateShop's Transaction URL.

  1. In the created script from Step 4, a http post to AffiliateShop's Transaction API is required.

  2. Note that the Affiliate AID parameter for the http post is retrieved from the 'custom' field from the IPN post.

After the http post to AffiliateShop's Transaction URL, the sale and commission should already be tracked and assigned to the Affiliate.