duanpuchun5275 2019-03-29 06:32
浏览 109

PHP - 从PayPal返回商家时没有收到交易信息

I have a paypal button on my page, where in I need to receive payment. I downloaded the code from HERE , all works fine it takes me to paypal page I can send money adn recieve it too(I am using sandbox account). However when transaction is complete and click on Return to merchant It shows me Payment has failed. I have $_GET['variable'] to access different transaction infos. Heres my code for `success.php' page :

/*include './db_config.php';*/
//Store transaction information into database from PayPal
$item_number = $_GET['item_number']; 
$txn_id = $_GET['tx'];
$payment_gross = $_GET['amt'];
$currency_code = $_GET['cc'];
$payment_status = $_GET['st'];
echo $txn_id;
//Get product price to store into database
$sql = "SELECT * FROM products WHERE id = '$item_number'";
$resultset = mysqli_query($conn, $sql) or die("database error:". 
$row = mysqli_fetch_assoc($resultset);
if(!empty($txn_id) && $payment_gross == $row['price']){
  //Insert tansaction data into the database
  mysqli_query($conn, "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 = mysqli_insert_id($conn);    
 <h1>Your payment has been successful.</h1>
 <h1>Your Payment ID - <?php echo $last_insert_id; ?>.</h1>
 <h1>Your payment has failed.</h1>

As you can see I tried to ECHO txn_id but no value. What am I missing here.

  • 写回答

1条回答 默认 最新

  • dtah63820 2019-04-05 05:11

    I have solved the issue it was just some settings that needs to be done on Paypal's side and its working, refer to THIS LINK
    1. I needed to change Auto Return for website payment to ON
    2. Under the Payment Data Transfer to ON
    and got the results

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



  • ¥15 remotes安装提示没有description文件
  • ¥15 AttributeError: 'NoneType' object has no attribute 'drop_duplicates'报错
  • ¥15 以下代码,运行结果报错
  • ¥15 Vivado仿真数据出错
  • ¥15 银河麒麟不支持vant等前端框架怎么办?
  • ¥15 vue3的子组件在父页面调用不显示不生效问题
  • ¥15 cadence PEX
  • ¥15 phython创建了文件 显示在项目下面,但运行不了,运行时还是运行main文件,并且说main文件不允许并行运行
  • ¥15 FutureWarning:不推荐使用空或全 NA 条目的 DataFrame 串联行为。怎么改呢?
  • ¥15 Chatgpt突然无法正常显示数学公式,如何解决?