为什么 PayPal IPN 事件侦听器无法识别付款验证
我设置了 PayPal IPN 侦听器,并且在去年 9 月(以及 8 年前)一直运行得很好,但现在当我今年尝试使用它时,它无法识别已验证或无效的付款。我使用了 PayPal Sandbox IPN Tester,它验证了是否正在进行“握手”,确实如此,但未进行付款验证。我也找不到任何有关 PHP PayPal IPN 脚本的最新信息,所以我很茫然。
这是我正在使用的精简版本:
$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";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen( 'ssl://ipnpb.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
$transaction_id = $_POST['txn_id'];
$email = $_POST['payer_email'];
$payment_status = strtolower(trim($_POST['payment_status']));
$last_name = $_POST['last_name'];
$first_name = $_POST['first_name'];
$member_id = cleanQuery($_POST['custom']);
if ($payment_status == "completed" || $payment_status == "pending") {
// DO STUFF IF PAYMENT STATUS IS COMPLETED
}
} else if (strcmp ($res, "INVALID") == 0) { // **********************PAYMENT INVALID OR DID NOT GO THROUGH
// Do stuff for UNFERIFIED
}
} // End Of While Loop
fclose ($fp);
} // Of if(!$fp)
I had a PayPal IPN Listener set-up and working perfectly fine all the way through September of last year (and 8 years prior), but now when I try to use it this year, it's not recognizing VERIFIED or INVALID payments. I used the PayPal Sandbox IPN Tester, and it verifies that the "handshake" is being made, which it is, but payment verification isn't being made. I can't find anything current about PHP PayPal IPN scripts either, so I'm at a loss.
Here is a stripped down version of what I'm using:
$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";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen( 'ssl://ipnpb.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
$transaction_id = $_POST['txn_id'];
$email = $_POST['payer_email'];
$payment_status = strtolower(trim($_POST['payment_status']));
$last_name = $_POST['last_name'];
$first_name = $_POST['first_name'];
$member_id = cleanQuery($_POST['custom']);
if ($payment_status == "completed" || $payment_status == "pending") {
// DO STUFF IF PAYMENT STATUS IS COMPLETED
}
} else if (strcmp ($res, "INVALID") == 0) { // **********************PAYMENT INVALID OR DID NOT GO THROUGH
// Do stuff for UNFERIFIED
}
} // End Of While Loop
fclose ($fp);
} // Of if(!$fp)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论