Ich bin Paypal Zahlung Gateway in einer der Website integriert. Nach erfolgreicher Zahlung ich es umleiten auf success.php
Datei. In success.php
Datei habe ich alle Einfügeparameter und eine Erfolgsmeldung enthalten. Es wird auf die Datei success.php
richtig umgeleitet, nachdem die Zahlung durchgeführt wurde, aber die Meldung "Zahlung fehlgeschlagen" angezeigt wird und keine Daten in die Datenbank eingefügt werden. Folgende ist meine success.php
Seite CodePaypal Zahlung Gateway Integration
<?php
include 'dbConfig.php';
//Get payment information from PayPal
$item_number = $_GET['item_number'];
$txn_id = $_GET['tx'];
$payment_gross = $_GET['amt'];
$currency_code = $_GET['cc'];
$payment_status = $_GET['st'];
//Get product price from database
$productResult = $db->query("SELECT price FROM products WHERE id = = '".$item_number."'");
$productRow = $productResult->fetch_assoc();
$productPrice = $productRow['price'];
if(!empty($txn_id) && $payment_gross == $productPrice){
//Check if payment data exists with the same TXN ID.
$prevPaymentResult = $db->query("SELECT payment_id FROM payments WHERE txn_id = '".$txn_id."'");
if($prevPaymentResult->num_rows > 0){
$paymentRow = $prevPaymentResult->fetch_assoc();
$last_insert_id = $paymentRow['payment_id'];
}else{
//Insert tansaction data into the database
$insert = $db->query("INSERT INTO payments(item_number,txn_id,payment_gross,currency_code,payment_status) VALUES('".$item_number."','".$txn_id."','".$payment_gross."','".$currency_code."','".$payment_status."')");
$last_insert_id = $db->insert_id;
}
?>
<h1>Your payment has been successful.</h1>
<h1>Your Payment ID - <?php echo $last_insert_id; ?></h1>
<?php }else{ ?>
<h1>Your payment has failed.</h1>
<?php } ?>
, was ich falsch mache?
Keine vorbereiteten Aussagen für einen. Sie sind [weit offen für SQL-Injection] (http://stackoverflow.com/documentation/php/5828/pdo/2685/preventing-sql-injection-with-parametrized-queries) – Machavity