gpt4 book ai didi

php - Paypal IPN 不是 "VERIFIED"或 "INVALID"

转载 作者:太空宇宙 更新时间:2023-11-03 15:46:41 25 4
gpt4 key购买 nike

我正在尝试在网站上集成 PayPal IPN。由于某种原因,IPN 监听器既不验证付款也不将其标记为无效。我在代码中的不同位置放置了 mail() 函数,以通知我有多少程序正在运行。

我试过在 $res 变量上使用和不使用 trim()。这两种方式都失败了。

这是我的代码:

    $req = 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
mail('test@test.net', 0, 0); //EMAIL RECEIVED
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);

$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'];
$last_name = $_POST['last_name'];
$address_street = $_POST['address_street'];
$address_city = $_POST['address_city'];
$address_zip = $_POST['address_zip'];
$address_state = $_POST['address_state'];
$address_country = $_POST['address_country'];
$contact_phone = $_POST['contact_phone'];
$payer_id = $_POST['payer_id'];


if (!$fp) {
//HTTP Error
mail('test@test.net', 1, 1);
} else {
fputs ($fp, $header . $req);
mail('test@test.net', 2, 2); //EMAIL RECEIVED
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp (trim($res), "VERIFIED") == 0) {
mail('test@test.net', 3, 3);
} else if (strcmp (trim($res), "INVALID") == 0) {
mail('test@test.net', 4, 4);
} else {
mail('test@test.net', 5, 5); //EMAIL RECEIVED
}
}
fclose ($fp);
}
}

我收到的电子邮件是 0、2 和 5。

最佳答案

刚刚回答了另一个和你一样的问题。 Paypal 已经停止支持 HTTP1.0。您的 header 现在应该显示为:

$header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Host:www.sandbox.paypal.com\r\n";
$header .= "Connection:close\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

如果直播,只需更改主机域名即可。

希望这对您有所帮助。

关于php - Paypal IPN 不是 "VERIFIED"或 "INVALID",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17902231/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com