【发布时间】:2019-04-26 19:13:16
【问题描述】:
我正在尝试使用PayPal-sandbox 建立我正在努力建立的在线商店。按照目前的情况,买家只需选择产品,点击立即购买按钮,然后发送到 PayPal 即可完成交易。
之后,我有一个函数利用返回 url 将交易详情存储在我的订单表中。
一切正常,但我想知道是否也可以使用退货 url 从 PayPal 表单中获取买家姓名和送货地址。
function process_transaction() {
if(isset($_GET['tx'])) { // ie. if transaction sale has been completed....
$amount = $_GET['amt']; // get amount details for our db
$currency = $_GET['cc'];
$transaction = $_GET['tx']; // get transaction details and we will bump into our db
$status = $_GET['st']; // get status, ie completed
$total = 0; // default product total variables set to zero in the first instance
$item_quantity = 0; // default quantity variable set to zero
$send_order = query(" INSERT INTO orders (order_amount, order_transaction, order_status, order_currency) VALUES('{$amount}','{$transaction}','{$status}','{$currency}')");
confirm($send_order);
$last_id = last_id();
foreach ($_SESSION as $name => $value) {
if($value > 0 ) {
if(substr($name, 0, 8) == "product_") {
$length = strlen($name) - 8;
$id = substr($name, 8 , $length);
$query = query(" SELECT * FROM products WHERE product_id = " . escape_string($id). " " );
confirm($query);
while ($row = fetch_array($query)) {
$product_price = $row['product_price'];
$sub = $row['product_price']*$value;
$item_quantity +=$value;
$insert_report = query(" INSERT INTO reports (product_id, order_id, product_price, product_quantity) VALUES('{$id}','{$last_id}','{$product_price}','{$value}')");
confirm($insert_report); //runs the confirm helper method
} // end of while loop
$total += $sub;
echo $item_quantity;
} // end of substring if statement
}
}
session_destroy();
} else {
redirect("index.php");
}
}
【问题讨论】:
-
返回 URL 是什么样的?你可以在这里发布一个例子吗?显然没有任何真实的客户数据,请......
-
好的,我马上就做,
-
@yinken 在上面添加了返回 url 数据示例的小图
标签: php html forms paypal paypal-sandbox