Upgrading Paypal IPN from HTTP/1.0 to 1.1 in PHP

For those, who are still running their Paypal IPN interface on the HTTP/1.0 protocol, the problems we saw today with Paypal might have been a wake-up call. IPN means Instant Payment Notification and triggers instant results for your customers, so you want to make sure, you got that tested before the 1st of February!

Paypal is working on the upgrade and in 4 days your old interface will stop working. I have upgraded several of our sites in the past six weeks and it is no biggie! BUT this how-to does not cover the problems you will run into.

Old 1.0 result

Old 1.0 result

The scripts out there compare the result lines of the IPN post in a string compare. Now the lines contain a “VERIFIED   ” – so some whitespaces and a

strcmp()

will not work! I have worked with a quick work-around and just TRIM the lines and then use the result line with a

substr_count()

which ultimately looks like:

if (substr_count($res, "VERIFIED") > 0)
{ ... your code ...}

So, to upgrade your script add the additional required lines to the request header

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

and make sure you check the result lines in a different way!

 

Comments are closed.