Published Tuesday 5th August 2014

Setting up a Paypal account to use with an IPN enabled shopping cart

Paypal is one of the nicest platforms to take online payments through. A developer can build Paypal integration in to just about any website relatively easily and most web users already know of and trust the service. You also don't usually need to worry about securing a website with an SSL certificate as Paypal payments are taken off-site.

Most Paypal integrations make use of Instant Payment Notifications, or IPN. Essentially, when your Paypal account receives a payment, it notifies a script on your website so that the website can acknowledge the payment, perhaps to reduce stocks or to flag an order as paid and ready for shipping.

Actual integration is dependent on specific project requirements, but, regardless of how your website works, if you want to use IPN you need to enable it in your Paypal account. Here's how:

  • Log in to your Paypal account and navigate to Profile & Settings via the icon in the upper right.
  • From the left, navigate to Selling Preferences.
  • Then from the list on the right, IPN Settings.
  • You want to enable IPN from the options on this page, but to do so you also need to provide an IPN notification url. This is the url of a script that receives payment notifications, but since you likely use your Paypal account for all sorts of things, you probably don't always want this to be the script used by the website you're enabling for. Instead, type in the url of a 'dummy script' and hit save.
  • You now need a dummy script at this address. Here's one that we built which you can give to your developer to put online. It doesn't do anything other than accept the notification to keep Paypal happy, but it could be extended to keep a log of all your incoming payments, for example.
    $req = 'cmd=_notify-validate';

    foreach($_REQUEST as $key => $value) {
        $value = urlencode(stripslashes($value));
        $req .= '&'.$key.'='.$value;

    $header = 'POST /cgi-bin/webscr HTTP/1.1'."\r\n"
             .'Content-Type: application/x-www-form-urlencoded'."\r\n"
             .'Content-Length: '.strlen($req)."\r\n"
             .'Connection: close'."\r\n\r\n";

    $fp = fsockopen('ssl://', 443, $errno, $errstr, 30);

    if($fp) {
        fputs($fp, $header.$req);

        while(!feof($fp)) {
            $res = fgets($fp, 1024);

        fclose ($fp);

You're now ready to use your account with an IPN enabled shopping cart, which should override this dummy script with it's own. Your developer just needs to know your merchant ID which is shown at the bottom of Profile & Settings.

Photo of Ric


Ric is a senior web and game programmer with nearly 30 years industry experience and countless programming languages in his skillset. He's worked for and with a number of design and development agencies, and is the proprietor of QWeb Ltd. Ric is also a Linux server technician and an advocate of free, open-source technologies. He can be found on Mastodon where he often posts about the projects he's working on both for and outside of QWeb Ltd, or you can follow and support his indie game project on Kofi. Ric also maintains our Github page of useful scripts.

Blog posts are written by individuals and do not necessarily depict the opinions or beliefs of QWeb Ltd or its current employees. Any information provided here might be biased or subjective, and might become out of date.

Discuss this post

Nobody has commented yet.

Leave a comment

Your email address is used to notify you of new comments to this thread, and also to pull your Gravatar image. Your name, email address, and message are stored as encrypted text. You won't be added to any mailing list, and your details won't be shared with any third party.

This site is protected by reCAPTCHA and the Google Privacy Policy & Terms of Service apply.