我正在创建一个网站,可以让我们使用 Paypal 提供的交易功能。
再次为了让网站完美运行,我正在使用沙盒帐户进行开发。
现在有两个名为return 和cancel_return 的参数。当交易成功完成时,贝宝网站将其重定向到返回参数中提到的页面,否则它会在 cancel_return 参数中返回。但网页没有重定向。当单击返回链接到网页时,它显示错误。
我的代码成功.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";
}
?>
它没有保存到数据库中并显示错误为
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
谢谢