Using the PayPal IPN, I keep getting an error 400.
I have been making the script send me emails of $res
to see what the response is, inside of the
I was having the same issues and these are the required changes. Some of the answers above dont fix all the problems.
New format for header:
$header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Host: www.sandbox.paypal.com\r\n"; // www.paypal.com for a live site
$header .= "Content-Length: " . strlen($req) . "\r\n";
$header .= "Connection: close\r\n\r\n";
Note the extra set of \r\n on the last line only. Also, the string compare no longer works because a newline is being inserted in the response from the server so change this:
if (strcmp ($res, "VERIFIED") == 0)
to this:
if (stripos($res, "VERIFIED") !== false) // do the same for the check for INVALID