Status pengembalian IPN Paypal memiliki huruf besar pertama.
Jadi Completed
tidak sama dengan completed
. Coba ini
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);
}
Lebih baik menyimpan status dalam variabel dan menggunakan php strtolower
berfungsi untuk membuatnya menjadi huruf kecil.
$paypalStatus = strtolower($_POST['payment_status']);
Kemudian lakukan cek seperti ini
if($paypalStatus == 'pending')