PayPal IPN不添加数据到我的数据库.但它在过去是有效的



我通过PayPal有很少的捐赠网页。它工作得很好,但几天前它停止工作,我不知道为什么。我在网上搜索PayPal的IPN是否更新了,但我什么也没找到。

当我在沙箱帐户上尝试它时。一切似乎都很顺利。它转到事务,然后返回给我返回url。我在沙箱帐户的通知中看到有关捐赠的交易,但应该将其放入我的数据库的部分不起作用。

我有这样的代码:Test.php里面的表单是用来存放捐赠详情(name…等):

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="sb-spoit2175143@business.example.com">
<!-- Specify a Donate button. -->
<input type="hidden" name="cmd" value="_donations">

<!-- Ostatní proměnné -->
<input type="hidden" name="cancel_return" value="donate_zruseno.php">
<input type="hidden" name="return" value="donate_dokonceno.php">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="notify_url" value="donate_test.php">
<input type="hidden" name="currency_code" value="CZK">

我的donate_test.php有这个:

<?php
$DATABASE_HOST = 'HOST';
$DATABASE_USER = 'USER';
$DATABASE_PASS = 'PASS';
$DATABASE_NAME = 'DATABASE';
$pripojeni = new mysqli($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_donations';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// Vyčteme nastavení z databáze.
$sql_nastaveni = mysqli_query($pripojeni, "SELECT sandbox, webhook FROM podpora_nastaveni");
while($db_nastaveni = mysqli_fetch_array($sql_nastaveni)) {
$nastaveni_webhook = $db_nastaveni['webhook'];
$sandbox = $db_nastaveni['sandbox'];
}
//post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.1rn";
$header .= "Host: www.sandbox.paypal.comrn";
$header .= "Content-Type: text/html; charset=utf-8";
$header .= "Content-Type: application/x-www-form-urlencodedrn";
$header .= "Content-Length: " . strlen($req) . "rnrn";
//$header .= "Connection: closern";
$fp = fsockopen ('ssl://sandbox.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) {
$sql = "INSERT INTO podpora (datum, discord, email, castka, cenzura, zprava, platnost) VALUES (NOW(), 'discord,', 'test@test.cz', '0', 'ne', 'test', '2022-12-10')";
mysqli_query($pripojeni, $sql);
} else if (strcmp (trim($res), "INVALID") == 0) {

}
}
fclose ($fp);
}

我试着把mysqli_query在if !fp是OK的,但仍然一切似乎都很好,但没有新的数据在数据库中。

我真的不知道哪里可以出错。你能帮我吗?

看起来好像事务根本不通过donate_test.php。如果我运行donate_test.php,第一个SQL INSERT将被添加到数据库中(因为它没有通过PayPal)。

同样的事情发生在我身上,它可以完美地处理订阅,但它不能处理像_xclick这样的正常事务。事实上,它甚至不会生成IPN消息

最新更新