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 :

<?php
include_once("db_connect.php");
/*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:". 
mysqli_error($conn));
$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>
<?php
}else{
?>
 <h1>Your payment has failed.</h1>
<?php
}
?>

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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵