数据库数据未插入

时间:2018-04-28 11:40:09

标签: php paypal-ipn

尝试使用PayPal安装IPN时,Payement数据仅保存在数据库中。

我已经尝试了一切。

我将PDO与MySQL和PayPal Sandbox一起使用。

这是我的保存数据

INSERT INTO payements ...工作,但DELETE和INSERT INTO赞助不会

$item_number = $_POST['item_number'];
$txn_id = $_POST['txn_id'];
$payment_gross = $_POST['mc_gross'];
$currency_code = $_POST['mc_currency'];
$payment_status = $_POST['payment_status'];
$name = $_POST['name'];
$ip = $_POST['ip'];
$port = $_POST['port'];
$description = $_POST['description'];
$banner = $_POST['banner'];
$owner = $_POST['owner'];

//Check if payment data exists with the same TXN ID.
$prevPayment = $dbh->prepare("SELECT payment_id FROM payments WHERE txn_id = ?");
$prevPayment->execute(array($txn_id));
if($prevPayment->rowCount() > 0){
    exit();
}else{
    //Insert tansaction data into the database
    $sql = $dbh->prepare("DELETE FROM pendingservers WHERE ip = ?");
    $sql->execute(array($ip));
    $query = $dbh->prepare("INSERT INTO sponsored 
                                    (name, ip, port, description, banner, owner) 
                             VALUES (?, ?, ?, ?, ?, ?)");
    $query->execute(array($name, $ip, $port, $description, $banner, $owner));
    $insert = $dbh->prepare("INSERT INTO payments 
                                    (item_number,txn_id,payment_gross,
                                     currency_code,payment_status)
                             VALUES (?, ?, ?, ?, ?)");
    $insert->execute(array($item_number, $txn_id, $payment_gross,
                            $currency_code, $payment_status));
}

仅保存Payement数据(交易ID等)

0 个答案:

没有答案