I am testing integrating a website to Paypal, using Web Payments standard and HTML Variables.
I have written a simple PHP script to handle the IPN notifications.
According to the Paypal documentation, the Paypal server responds with a simple 'VERIFIED' or 'INVALID' response, once you ping the received data back to Paypal.
In my handler, I am doing a case sensitive string comparison for those two keywords, if either one of these known keywords is not found, then it is treated as an error.
<?php
$fp = fsockopen ($socket_url, 80, $errno, $errstr, 10);
if (!$fp){
// SOCKET ERROR
return false;
}
else {
fputs ($fp, $header . $req);
$is_ok = false;
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp("VERIFIED",$this->ipn_response)==0) {
//do something ...
}
// if the IPN POST was 'INVALID'
else if (strcmp ($res, "INVALID") == 0) {
fclose ($fp);
return false;
}
else {
echo "Unknown response from Paypal: $res";
fclose ($fp);
return false;
}
}
fclose ($fp);
return true;
}
?>
My error message shows that I am receiving an 'HTTP/1.1 200 OK' response from Paypal.
Unknown response from Paypal: 'HTTP/1.1 200 OK'
Has the PayPal API changed, or am I doing something wrong?