php - PHP - 从贝宝返回商家时未获取交易信息
问题描述
我的页面上有一个贝宝按钮,我需要在其中接收付款。我从这里下载了代码 ,一切正常,我可以转到贝宝页面,我也可以汇款和收款(我使用的是沙盒帐户)。但是,当交易完成并单击Return to merchant
它显示我Payment has failed
。我必须$_GET['variable']
访问不同的交易信息。这是我的“success.php”页面代码:
<?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
}
?>
如您所见,我尝试 ECHO txn_id 但没有价值。我在这里想念什么。
解决方案
我已经解决了这个问题,它只是一些需要在 Paypal 端完成的设置及其工作,请参阅此链接
1。我需要将网站支付的自动返回更改为 ON
2。在支付数据传输下,设置为 ON
并得到结果
推荐阅读
- android - 我应该将此 json 数据文件视为对象还是数组
- swift - Swift - nextDate() 按年份搜索
- azure-storage - 使用 Microsoft Azure Storage SDK for Node.js 和 JavaScript for Browsers 在浏览器中显示来自 azure blob 的 PDF
- jquery - Events Calendar Pro 不会在 AJAX 加载的页面上刷新
- javascript - mathjs eval 错误:(中间值)(中间值)(中间值)不是函数
- python - django无法运行manage.py runserver如何解决?
- android-studio - 如何在我的 Windows 上从克隆的 repo 运行 React-Native-Navigation v2 Playground?
- node.js - 可以将数据添加到某些 MongoDB 集合的命令中吗?
- python-3.x - 美丽的汤 td 类名相同,我需要通过文本获取第 1 到第 4 值的值
- mongoose - 猫鼬选择错误