IPN FAILING (No Response Code 200?)

weissmar48
Contributor
Contributor

I recently received an email from PAYPAL saying that our IPN Listener is failing.  Nobody has touched that code in about 7 years.  I looked at it, and the only thing I can see wrong is, I don't see an HTTP Response Code 200 being sent.  Was this requirement added in the past 7 years?  This code is PHP.  Can anyone help me to modify the code to send the HTTP Response Code 200?  Code is below:

<?php

$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\nHost: ipnpb.paypal.com:443\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\nContent-Length: ";
$header .= strlen($req) . "\r\n\r\n";

$fp = fsockopen('ssl://ipnpb.paypal.com', 443, $errno, $errstr, 30);

$today = $_POST['payment_date'];
$lastname = $_POST['last_name'];
$amount = $_POST['payment_gross'];
$currency = $_POST['mc_currency'];
$fee = $_POST['mc_fee'];
$firstname = $_POST['first_name'];
$jwvemail = $_POST['receiver_email'];
$invoice = $_POST['invoice'];
if (!$fp) {
$ipn_verified = false;
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp (trim($res), "VERIFIED") == 0) {
$ipn_verified = true;
break;
} else if (strcmp (trim($res), "INVALID") == 0) {
$ipn_verified = false;
break;
}
}
}

fclose($fp);

Login to Me Too
1 REPLY 1

MTS_Chiranjeevi
Moderator
Moderator

Good day @weissmar48,

 

Thank you for contacting PayPal community.

 

Our sincere apologies for the inconvenience caused.

 

Merchants should handle their IPN server script code and return 200 OK to PayPal system.

Failed : PayPal never received an HTTP 200 OK response to the original POST or to any of the subsequent re-POSTs.
Retrying : PayPal did not receive an HTTP 200 OK response to the original POST, the message has been re-POSTed between one and fifteen times, and PayPal is continuing to re-POST the message.

I suggest to please contact your website developer to cross check your IPN listener server, to receive IPN responses from PayPal system.

Please refer the detailed guide link to resolve the issue -

https://developer.paypal.com/docs/api-basics/notifications/ipn/IPNTesting/?mark=ipn%20trou#ipn-troub...

If you see many Failed or Retrying entries, not sending HTTP 200 OK responses is probably causing your IPN delays. To fix this, go through your server logs to determine why HTTP 200 OK responses are not being sent and fix your listener. Once your listener is sending HTTP 200 OK responses as required, PayPal posts IPNs from the faster-cycling server.

PayPal system sends the IPN response payload to the specific IPN listener endpoint URL. If your(merchant) IPN listener server fails to send HTTP 200 OK response.


The IPN History page on the PayPal website enables you to verify and troubleshoot IPN messages. Use the IPN History page to determine the status of IPN messages, view message details, and to resend them, if necessary, as described in these procedures. 

https://developer.paypal.com/api/nvp-soap/ipn/IPNOperations/  

Before you can trust the contents of the message, you must first verify that the message came from PayPal. To verify the message, you must send back the contents in the exact order they were received and precede it with the command _notify-validate

PayPal will then send one single-word message, either VERIFIED, if the message is valid, or INVALID if the messages is not valid.


https://developer.paypal.com/api/nvp-soap/ipn/IPNIntro/#link-asampleipnmessageandresponse 

Thank you so much for your patience and understanding.

 

Sincerely,

Chiranjeevi

PayPal/Braintree MTS

 

If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.

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.