Help Article

How do I modify my IPN PHP listener to support HTTP1.1?

Important: PayPal has required the use of HTTP 1.1 since October 2013.

To modify your IPN PHP listener to support HTTP1.1, you need to include the "Host" and "Connection" headers in the IPN postback script. The following example shows how: PHP
// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Host: www.paypal.com\r\n";
$header .= "Connection: close\r\n\r\n";
Note: For further compatibility, your PHP script should also trim the IPN validation response. Modify your script from this:
 
if (strcmp ($res, "VERIFIED") == 0) {
..
else if (strcmp ($res, "INVALID") == 0) {
To this:
 
if (strcmp (trim($res), "VERIFIED") == 0) {
..
else if (strcmp (trim($res), "INVALID") == 0) {
In PHP, check that the last line of your header includes double end-of-line markers: \r\n\r\n as in the next example:
 
$header .="Connection: close\r\n\r\n";
In PHP, open the socket connection to the same host declared in the header. Your header is declaring the host as:
 
$header .="Host: www.paypal.com\r\n";
You should open the connection to the same host:
 
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

Note: For new IPN integrations, we recommend these updated samples.
We’re sorry. The page you’re looking for is no longer available. To search again or contact us, please visit our Help Centre.