Sandbox paypal测试帐户不返回变量

时间:2016-02-04 12:32:56

标签: php paypal sandbox

我有两个paypal测试帐户。一个是" testaddabusiness@shop.com"另一个是" testaddapersonal@shop.com"。它们都用于测试我的交易。我按照教程制作了一个与paypal集成的购物车。问题是它没有返回我需要保存在数据库表中的一些变量。我已使用success.php设置了网站首选项。它没有从paypal返回付款细节。

success.php

<?php
session_start();
include("db/db.php");
error_reporting(E_ALL);
ini_set('display_errors', 1);
?>
<html>
<title>Success</title>
<body>
<?php
if(isset($_SESSION['cart']) && isset ($_SESSION['login_email'])){
$total=0;
$ships=$_POST['shipment'];
$user=$_POST['name'];
$user_id=$_POST['id'];
$file=$_FILES['file']['name'];


//orders and order details.
$que=mysqli_query($con,"insert into orders(custom_file,date,customerid,ship_days) values('$file',CURRENT_TIMESTAMP(),'$user_id','$ships')");
if($que)
{
$m=move_uploaded_file($_FILES['file']['name'],'./ServerUploadedFiles/'.$user.$file);

$q=mysqli_query($con,"select serial from orders where customerid='$user_id' and date=CURRENT_TIMESTAMP()");
while($row1=mysqli_fetch_array($q,MYSQLI_ASSOC))
{
$order_id=$row1['serial'];

}
foreach($_SESSION['cart'] as $id => $value){

$subtotal=$value['price']*$value['quantity'];
$pid=$value['id'];
$quantity=$value['quantity'];
$color=$value['color'];
$size=$value['size'];
$total+= $subtotal;

$query= mysqli_query($con, "INSERT INTO order_detail(orderid,productid,quantity,price,color,size) VALUES ($order_id, $pid, $quantity, $subtotal, '$color', '$size')");

}  
}
//payment details for paypal
    $amount=$_GET['amt'];
    $currency=$_GET['cc'];
    $trx_id=$_GET['tx'];
    $insert_payments= mysqli_query($con,"insert into payments(amount,cust_id,trx_id,currency) values('$amount','$user_id','$trx_id','$currency')");

    if($amount==$total)
    {
      echo "<h2>Hello". $user."You have successfully done purchasing process.Please <a href='profile.php'>Go to your account</a>!</h2>";
    }
    else
    {
        echo "<h2>Hello". $user."Your payment was not successful.Please <a href='profile.php'>Go to your account</a>!</h2>";
    }
 }
?>

</body>
</html>

form.php的

  <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"  enctype="multipart/form-data">
   <?php
   $email=$_SESSION["login_email"];
   $query=mysqli_query($con,"select * from customers where email='$email'");
    while($row=mysqli_fetch_array($query,MYSQLI_ASSOC))
     {
     ?>
    <input type="hidden" class="input_form" name="id" value="<?=$row["serial"]?>">
    <input type="hidden" class="input_form" name="name" value="<?=$row["name"]?>">
    <input type="hidden" class="input_form" name="phone"  value="<?= $row["phone"] ?>">
    <input type="hidden" class="input_form" name="city"  value="<?= $row["city"] ?>">
    <input type="hidden" class="input_form" name="address"  value="<?= $row["address"] ?>">
   <a href="download.php?download_file=custom-measurement-form.pdf">Download custom size form Provide us your custom size</a>
    <input type="file" name="file">
    Select shipment interval (optional):<select id="shipment" name="shipment">
      <option  selected value="7" id="7">7</option>
      <option value="6" id="6"> 6 </option>
      <option value="5" id="5">5 </option>
      <option value="4" id="4">4 </option>
       <option value="3" id="3">3 </option>
       </select>
       <p>Before clicking submit read <a href="http://localhost/WebProject_Adda/index.php?page=policies">Terms and Policies</a> carefully..Once ordered would not be restored.</p>
       <input type="checkbox" value="I accept the terms and policies by Aada Fashion.">I accept the terms and policies by Aada Fashion.
         <?php
        }
         ?>
 <!-- Identify your business so that you can collect the payments. -->
     <input type="hidden" name="business" value="testaddabusiness@shop.com">
 <!-- Specify a Buy Now button. -->
     <input type="hidden" name="cmd" value="_cart">
     <input type="hidden" name="upload" value="1">
   <?php
      if(isset($_SESSION['cart'])){
         $count=1;
         foreach($_SESSION['cart'] as $id => $value){
          ?>
       <input type="hidden" name="item_number_<?php echo $count ?>" value="<?php echo $value['id']  ?>">
        <input type="hidden" name="item_name_<?php echo $count ?>" value="<?php echo $value['name']  ?>">
        <input type="hidden" name="quantity_<?php echo $count ?>" value="<?php echo $value['quantity'] ?>">
          <input type="hidden" name="amount_<?php echo $count ?>" value="<?php echo $value['price']   ?>">
           <input type="hidden" name="on1_<?php echo $count ?>" value="<?php echo $value['color'] ?>">
          <input type="hidden" name="on0_<?php echo $count ?>" value="<?php echo $value['size']   ?>">
          <input type="hidden" name="currency_code" value="USD">
        <?php
         $count++;
           }
          }
       ?>
<input type="hidden" name="return" value="http://abc/WebProject_Adda/success.php">
<input type="hidden" name="cancel_return" value="http://abc/WebProject_Adda/paypal_cancel.php">
 <input type="image" name="submit" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal - The safer, easier way to pay online">
  <img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>

0 个答案:

没有答案