IPN management fails at least since September 8th

Arthurbro
Contributor
Contributor
Hello,
 
I have a PHP script managing IPN which has worked for years at least until September 5th.
I started having issues from September 8th without any change on my side. IPN are sent by Paypal, but my listener script now fails every time.
I can conclude something changed on PayPal between September 5th and September 8th.
 
The issue occurs on the below sample code (which has worked flawless for years).
------------------------------------------------------------------------------------
$req = 'cmd=_notify-validate';
 
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
 
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
 
if ($fp) 
{
fputs($fp, $header . $req);
----------------------------------------------------------------------------
 
Here is what I get in $fp  :
Server: AkamaiGHost  
HTTP/1.0 400 Bad Request
Invalid URL
The requested URL "[no URL]", is invalid. 
 
I get this every time PayPal sends an IPN to my script.
 
Can someone help me about this ? 
 
Thank you very much for your help.
 
Arthur
Login to Me Too
5 REPLIES 5

Neliger
Contributor
Contributor

I've tha same problem, and looking to the documentation here : https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNImplementation/#specs

 

If I understand well, I thing the verify address has moved to https://ipnpb.paypal.com/cgi-bin/webscr

Login to Me Too

Arthurbro
Contributor
Contributor

I've  tried to replace the line :

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

by

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

 

Unfortunately, my IPN script still fails... Can I have official help from PayPal on this ? It's a real problem, I have to perform actions manually each time I receive a payment...

 

Thanks in advance

Login to Me Too

MTS_Ciaran
Moderator
Moderator

Hey, 

 

Can you try setting the URL to https://ipnpb.paypal.com/cgi-bin/webscr" and let me know if you are still seeing the issue?

Login to Me Too

Arthurbro
Contributor
Contributor

Hi,

 

Thanks for your message. Actually, as I wrote in my previous post, I tried to replace the line : 

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

by

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

 

But it also fails.

 

You have the whole code sample in my first post... Did you have something else in mind ?

 

 

Login to Me Too

Gutore
New Community Member

Hi,

 

I think the issue is that you are using HTTP1.0 (Note that HTTP1.1 was released in 1997).

Specifically HTTP1.0 allows requests without "host" header (which became mandatory in HTTP1.1, RFC 2068: https://tools.ietf.org/html/rfc2068#section-14.23

 

Two ways to fix your issue:

1) Change

$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";

with 

$header .= "POST /cgi-bin/webscr HTTP/1.1\r\n";

 

Your server should send host header by default.

 

2)

Add in your code 

$header .= "Host: www.paypal.com\r\n";

 

Please let me know if it works.

 

G.

 

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.