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 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘