cancel
Showing results for 
Search instead for 
Did you mean: 

IPN issues

Highlighted
Contributor

IPN issues

I have a site with a custom paypal payment button which was all working fine up until Aug 30th 2018. 

Normally payments would go through, an IPN would be sent and posted back looking like the following from the server logs:

"POST /ipn.php HTTP/1.1" 200 3 "-" "PayPal IPN ( https://www.paypal.com/ipn )"

This would trigger the backend functions and write the order to database successfully.

 

When payments stopped working I would see the following in the logs, which has a slightly different status of 407, following the 200

"POST /ipn.php HTTP/1.1" 200 407 "-" "PayPal IPN ( https://www.paypal.com/ipn )"

 

I read on the forum that some members were also having IPN issues and had either reissued SSL certificates or downgraded from TLS 1.3 to 1.2. But there were no concrete explanations of why the error had suddenly occurred. As these were hosting related I contacted my host who are always very obliging and knowledgeable. They suggested the code  discrepancies could be caused by the Mod_security module on an apache web server throwing false positives because the IPNs are wrongly detected as malicious behaviour. They 'white listed' certain rules to try and remedy the situation but still the payment process was not working our end. In fact the IPN from server log now had a  422 following the 200 as follows:

POST /ipn.php HTTP/1.1" 200 422 "-" "PayPal IPN ( https://www.paypal.com/ipn )"

 

Currently we are still not able to full fill orders on a normal basis when paypal is used and these IPN anomalies must have something to do with it. To be honest I am not the most advanced PHP programmer or PayPal expert..is there anyone out there who can shed some light on how we could solve this issue please?

 

 

 

 

5 REPLIES
Volunteer Advisor

Re: IPN issues

There was some issue with IPN in the passed few days, but I don't think it started at the end of August. Are you seeing anything in the PayPal IPN History for the account?
Angell EYE - www.angelleye.com
PayPal Partner and Certified Developer - Kudos are Greatly Appreciated!
Contributor

Re: IPN issues

I checked the IPN history as suggested. Our last successful payment with paypal was on the 3rd Sept.

Then 4 subsequent payments starting on the 10th Sept went through OK with Paypal but failed to trigger our backend/admin processes.

The IPN history states all payments went through with a 200 and 'completed'. However if you look at the server logs  you can see the IPN code we are posting has changed since the 10th as follows:

 

"POST /ipn.php HTTP/1.1" 200 407 "-" "PayPal IPN ( https://www.paypal.com/ipn )"

//Note the 407 following the 200.

 

Compare this with the IPN we previously sent when payments completed our end too on the 3rd with the following:

"POST /ipn.php HTTP/1.1" 200 3 "-" "PayPal IPN ( https://www.paypal.com/ipn )" 

//Note the 3 following the 200.

 

So something has changed with Paypal. I don't really know how to fix this issue for my client, will it pass with time once Paypal are made aware? It seems many loyal paypal customers are having the same frustration. Or do I need a developer to have a look? We have made no changes to the payment flow or IPN ‘listener page’ so I am open to your best advice.

Volunteer Advisor

Re: IPN issues

That 3 or 407 really shouldn't have anything to do with your validation. Can you post a sample of your IPN script for review?
Angell EYE - www.angelleye.com
PayPal Partner and Certified Developer - Kudos are Greatly Appreciated!
Contributor

Re: IPN issues

Here is the complete IPN:

 

 

 

<?php
// PHP 4.1
$paypal_sandbox = false;

// 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.1\r\n";

if ($paypal_sandbox)
$header .= "Host: www.sandbox.paypal.com\r\n";

$header .= "Content-Type: application/x-www-form-urlencoded\r\n";

$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

if ($paypal_sandbox)
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
else
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);


// assign posted variables to local variables

$item_name = $_POST['item_name'];

$item_number = $_POST['item_number'];

$payment_status = $_POST['payment_status'];

$payment_amount = $_POST['mc_gross'];

$payment_currency = $_POST['mc_currency'];

$txn_id = $_POST['txn_id'];

$receiver_email = $_POST['receiver_email'];

$payer_email = $_POST['payer_email'];

 

if (!$fp) {
mail('<an email address>', 'ERROR CONNECTING', $errno.' '.$errstr);
// HTTP ERROR

} else {
fputs ($fp, $header . $req);

while (!feof($fp)) {

$res = fgets ($fp, 1024);


if (strcmp ($res, "VERIFIED") == 0) {

session_id($_POST['custom']);

session_start();

$data = file_get_contents('temp/data/'.$_POST['custom']);
mail('<an email address>', 'DATA', $data);

$_SESSION = unserialize($data);

include_once('config.php');
if(isset($_SESSION['uid']) && $_SESSION['uid'] != 0)
$order_number = orderpayment(1);
else
$order_number = orderpayment();

if (is_file('temp/data/'.$_POST['custom'])) {
//@unlink('temp/data/'.$_POST['custom']);

$_SESSION['order_number'] = $order_number;

// append the order number to the file
$h = fopen('temp/data/'.$_POST['custom'], 'w');
fwrite($h, serialize($_SESSION));
fclose($h);
}


} else if (strcmp ($res, "INVALID") == 0) {

// log for manual investigation

}

}

fclose ($fp);

}

?>

Volunteer Advisor

Re: IPN issues

I'm not familiar with what that second number means, but any time I've ever seen 200 that means the script completed successfully. If the actions you expected to occur are not happening, maybe something about the logic needs adjustment..?? For example, maybe there is some if/then logic that ends up skipping most of your code so nothing runs, but the script itself returns a 200 OK response.

I would recommend following these steps (https://www.angelleye.com/test-paypal-ipn/) to see if you can get somewhere with troubleshooting.

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