请提前原谅我的无知,但我对 php 还很陌生,这个问题一直困扰着我一段时间。我正在尝试为销售单个商品的在线商店编写 IPN 脚本。付款完成后,脚本将更新数据库并将可用性从“可用”更改为“不可用”。除了更新数据库外,IPN 似乎工作正常。我现在不知所措,因为我看不出脚本有什么问题。这就是我所拥有的:
curl_close($ch);
if (strcmp ($res, "VERIFIED") == 0) {
$token = $_POST['invoice'];
$item= $_POST['invoice'];
$conn=new PDO("mysql:host=SERVER;dbname=MYDATABASE","NAME","PASS");
if ($_POST['payment_status'] == 'completed')
{
$sql="UPDATE `tbl_products` SET `id_status` = 3 WHERE `id_product`=:idproduct";
$stmt=$conn->prepare($sql);
$stmt->bindParam(':idproduct',$item);
$stmt->execute();
}
if ($_POST['payment_status'] == 'pending')
{
$sql="UPDATE `tbl_products` SET `id_status` = 2 WHERE `id_product`=:idproduct";
$stmt=$conn->prepare($sql);
$stmt->bindValue(':idproduct',$item);
$stmt->execute();
}
foreach ($_POST as $key => $value)
{
$emailtext .= $key . " = " .$value ."\n\n";
}
mail("MYEMAIL", "Live-VALID IPN", $emailtext . "\n\n" . $req);
}
else if (strcmp ($res, "INVALID") == 0)
{
// log for manual investigation
foreach ($_POST as $key => $value)
{
$emailtext .= $key . " = " .$value ."\n\n";
}
mail("MYEMAIL", "Live-INVALID IPN", $emailtext . "\n\n" . $req);
}