I had installed IPN on my account which seems to be working on IPN simulator, but when testing on Sandbox mode, it is not working. This is my code, am I having something wrong?
<?php
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
//Set up the acknowledgement request headers
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Host: www.sandbox.paypal.com\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
//Open a socket for the acknowledgement request
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
// Post request back to PayPal for validation
fputs ($fp, $header . $req);
while (!feof($fp)) { // While not EOF
$res = fgets ($fp, 1024); // Get the acknowledgement response
if (strcmp ($res, "VERIFIED") == 0) { // Response is VERIFIED
// Send an email announcing the IPN message is VERIFIED
$mail_From = "IPN@example.com";
$mail_To = "me@gmail.com";
$mail_Subject = "VERIFIED IPN";
$mail_Body = $req;
mail($mail_To, $mail_Subject, $mail_Body, $mail_From);
}
else if (strcmp ($res, "INVALID") == 0) { // Response is INVALID
// Notification protocol is NOT complete, begin error handling
// Send an email announcing the IPN message is INVALID
$mail_From = "IPN@example.com";
$mail_To = "me@gmail.com";
$mail_Subject = "INVALID IPN";
$mail_Body = $req;
mail($mail_To, $mail_Subject, $mail_Body, $mail_From);
}
}
fclose ($fp);
?>
Is it something that I have wrong in the code or is it a problem from Paypal? How can I solve this problem?
On other hand, my account is verified with Paypal
I've got the same trouble,
But the problem is from Paypal sandbox interface, there server didn't call my notification url.
It seems riht now,
Please Try again!
:)
Apparently it is a problem in Paypal documentation, and yesterday I discovered I needed to do these steps:
The code is working perfectly, it was a matter of mysterious settings.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.