drj26159 2012-09-06 13:44
浏览 44
已采纳

Paypal交易

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

  • 写回答

1条回答 默认 最新

  • dsfs21312 2012-09-06 13:53
    关注

    This is a notice error. This means that some of your $_GET variables are not set.

    An example to get rid of this error message is to switch how you assign the variables... such as

    $item_no = isset($_GET['item_number']) ? $_GET['item_number'] : null;
    

    You can also disable notices by changing the variable error_reporting in php.ini but this is not recommended on a development machine

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 yolov8边框坐标
  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真