IPN Verification on Subscriptions No Longer Working

findcaregiver
New Community Member

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.

Login to Me Too
3 REPLIES 3

angelleye
Advisor
Advisor
You need to update your script to use HTTP 1.1 instead of 1.0, which is not a requirement of PayPal. More info on that available here:

https://www.paypal-community.com/t5/PayPal-Payments-Standard/Postback-to-PayPal-suddenly-stopped-wor...

Angell EYE - www.angelleye.com
PayPal Partner and Certified Developer - Kudos are Greatly Appreciated!
Login to Me Too

docSnob
Contributor
Contributor

In the first sentence, is the word "not" a typo?  Should it be "now"?

 

"You need to update your script to use HTTP 1.1 instead of 1.0, which is NOW a requirement of PayPal. More info on that available here:"

Login to Me Too

filipporonco
Contributor
Contributor

Hi @angelleye can you please give a look to this issue that is ongoing from July 1st and that does affect a lot of users even if paypal doesn't make any mention of it in the paypal status website? Thanks
https://www.paypal-community.com/t5/PayPal-Reporting/Malformed-IPNs-the-response-contains-unreadable...

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.