I am creating a website that can offer us to use the transaction feature given by Paypal.
Again for the website to work perfectly I am using sandbox account for my developing.
Now there are two parameters named return and cancel_return. when transaction is completed successfully paypal website redirect it to page mentioned in return parameter otherwise it returns in cancel_return parameter.but web page is not redirect .while clicking return link to webpage it showing error.
my code success.php
<?php
define("DB_HOST", "localhost");
define("DB_USERNAME", "root");
define("DB_PASSWORD", "");
define("DB_DATABASE", "test");
$connect = mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD) or
die("Database Connection Error");
mysql_select_db(DB_DATABASE) or ("Database Selection Error");
session_start();
$uid = $_SESSION['uid'];
$username=$_SESSION['username'];
$item_no = $_GET['item_number'];
$item_transaction = $_GET['tx'];
$item_price = $_GET['amt'];
$item_currency = $_GET['cc'];
//Getting product details
$sql=mysql_query("select product,price,currency from products where pid='$item_no'");
if($sql === FALSE) {
die(mysql_error()); // TODO: better error handling
}
$row=mysql_fetch_array($sql);
$price=$row['price'];
$currency=$row['currency'];
//Rechecking the product details
if($item_price==$price && $item_currency==$currency)
{
$result = mysql_query("INSERT INTO sales(pid, uid, saledate,transactionid)
VALUES('$item_no', '$uid', NOW(),'$item_transaction')");
if($result){
echo "<h1>Welcome, $username</h1>";
echo '<h1>Payment Successful</h1>';
}else{
echo "Payment Error";
}
}
else
{
echo "Payment Failed";
}
?>
It not saving into database and showing error as
Undefined index: item_number in C:\wamp\www\mvc\view\success.php on line 13
Undefined index: tx in C:\wamp\www\mvc\view\success.php on line 14
Undefined index: amt in C:\wamp\www\mvc\view\success.php on line 15
Undefined index: cc in C:\wamp\www\mvc\view\success.php on line 16
Thanks