Paypal IPN geretourneerde status heeft het eerste teken in hoofdletters.
Dus Completed
is niet gelijk aan completed
. Probeer dit
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);
}
Het is beter om de status in een variabele op te slaan en php strtolower
te gebruiken functie om ze in kleine letters te maken.
$paypalStatus = strtolower($_POST['payment_status']);
Doe de controle dan zo
if($paypalStatus == 'pending')