At some point in the last few months, the IPN verification I use on the site is no longer working. The URL of the IPN script is being triggered by PayPal's response, but the check for VERIFICATION doesn't happen anymore. This is for a subscription transaction.
Below is the basic framework of code I've been using. And like I said, up until a few months ago, it was working fine. I should also add that the PayPal account changed in that time too, although I don't see how that would have affected it. The IPN setting is set to on, and the URL is being properly triggered.
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$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) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) { // ****************************** PAYMENT IS VERIFIED
foreach($_POST as $key => $value){
echo $key." = ". $value." ";
}
if($transaction_type == 'subscr_signup') {
} else if($transaction_type == 'subscr_payment') {
} else if($transaction_type == 'subscr_cancel') {
} else if($transaction_type == 'subscr_eot') {
}
//*******************************************************************************************************************//
} else if (strcmp ($res, "INVALID") == 0) { // **********************PAYMENT INVALID OR DID NOT GO THROUGH
}
} // End Of While Loop
fclose ($fp);
} // Of if(!$fp)
One last thing. I inserted some error logging into this script (not shown in the framework above), and for the response code, I am getting HTTP/1.0 400 Bad Request, and Invalid URL messages. I just don't know what that could be referring to.
Thanks for any help provided.
... View more