为什么 PayPal IPN 事件侦听器无法识别付款验证

发布于 2025-01-14 05:19:16 字数 1569 浏览 2 评论 0原文

我设置了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文