IPN listener stopped working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Several years ago I created an IPN listener (using PHP) based on a code sample that was provided by PayPal's Integration Guide(s).
It worked beautifully for years - and then stopped!
PayPal support say that the IPN is working and that my listener is correctly verifying the responses etc but it won't do what it used to do.
I have a feeling that PayPal have changed things and left my code behind. I have looked on github but the example code they are giving does not make sense to me.
Please can someone help. I have copied my listener code below. Can someone please just tell me what is wrong and what I need to do. This is driving me up the wall!
Thank you very much...
<!DOCTYPE html>
<html lang="en">
<head>
<title>Untitled Document</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
<body>
<?
// 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";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Host: www.paypal.com\r\n";
$header .= "Connection: close\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( trim( $res ), "VERIFIED" ) == 0 )
{
// 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' ];
$first_name = $_POST[ 'first_name' ];
if ( $payment_status == "Completed" )
{
// I have some PHP code here (irrelevant to the operation of this listener)
}
} else if ( strcmp( trim( $res ), "INVALID" ) == 0 )
{
// log for manual investigation
// the code here is never activated either!
}
}
fclose( $fp );
}
?>
</body>
</html>
- Labels:
-
IPN
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This happened to me last month. I may have solved it, but I'm not sure yet, even though it has worked in testing. Did you figure it out?
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- My webhook stopped working 2 weeks ago in REST APIs
- Adaptive Payments stopped working in early Feb 2024 in NVP/SOAP APIs
- Encrypted subscription button has stopped working in NVP/SOAP APIs
- PayPal Native checkout card errors in Sandbox Environment
- Website payment preferences, auto return stopped working with new subscription payment button in PayPal Payments Standard