Ok, so I have recently started trying to work with PayPals IPN, I have read some of PayPals pages on their IPN and used the PHP source from here: https://developer.paypal.com/docs/classic/ipn/gs_IPN/, I have ended up with this entire code:
<?php
header('HTTP/1.1 200 OK');
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
$header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$header .= "Host: www.sandbox.paypal.com:443\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
fputs($fp, $header . $req);
while (!feof($fp))
{
$res = fgets($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
} else if (strcmp ($res, "INVALID") == 0) {
}
fclose ($fp);
}
?>
When I use PayPal's IPN simulator it says
IPN was not sent, and the handshake was not verified. Please review your information.
This is strange because it seems as though i read PayPal's PHP documentation correctly and this code seems like it should work? What could Possibly going wrong?
Try logging in back-end. Sometimes PayPals IPN listener says handshake was invalid even though it was.