i have a little problem and i have no clue on how to solve it, i´ve tried everything i could and i have no idea where the problem is, the thing is that after the ipn listener insert the transaction data into the ipn_data_tbl, i want to update the record with the same value as $custom, but is not working, is the only thing i need, everything else but this is working as expected, this is my code:
$tokens = explode("\r\n\r\n", trim($res));
$res = trim(end($tokens));
if (strcmp($res, "VERIFIED") == 0 || strcasecmp($res, "VERIFIED") == 0) {
//Payment data
$item_name = $_POST['item_name'];
$txn_id = $_POST['txn_id'];
$payment_gross = $_POST['mc_gross'];
$currency_code = $_POST['mc_currency'];
$payment_status = $_POST['payment_status'];
$create_date = date('Y-m-d H:i:s');
$payment_date = date('Y-m-d H:i:s');
$payer_email = $_POST['payer_email'];
$txn_type = $_POST['txn_type'];
$custom = $_POST['custom'];
//Check if payment data exists with the same TXN ID.
$prevPayment = $con->query("SELECT UID FROM ipn_data_tbl WHERE txn_id = '".$txn_id."'");
if($prevPayment->num_rows > 0){
exit();
}else{
//Insert tansaction data into the database
$insert = $con->query("INSERT INTO ipn_data_tbl(item_name,txn_id,amount,currency,payment_status,create_date,payment_date,payer_email,txn_type,UID) VALUES('".$item_name."','".$txn_id."','".$payment_gross."','".$currency_code."','".$payment_status."','".$create_date."', '".$payment_date."','".$payer_email."','".$txn_type."','".$custom."')");
}
if ($con->query($insert) === TRUE) {
echo $update = $con->query("UPDATE `transportation` SET `paypal_status`='$payment_status' WHERE `id`='$custom'");
}
else {
$delete = $con->query("DELETE FROM transportation WHERE txn_id = '".$txn_id."'");
}
}