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 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据