我有一个关于php按钮的问题。我想用贝宝制作一个动态购买按钮。我可以将自定义变量传递给的按钮。我知道如何通过paypal形式的唯一方法。
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="paid@yourdomain.com">
<input type="hidden" name="item_name" value="my product">
<input type="hidden" name="item_number" value="12345">
<input type="hidden" name="amount" value="9.99">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
但上述表格的金额很容易被篡改。因此,我想在html中只有一个按钮,并通过一个php文件处理所有内容。当用户点击按钮时,价格计算过程将在php文件中进行,然后将用户重定向到paypal,他们可以在那里支付该项目。这样价格就不会被篡改。有人可以告诉我是否可以这样做?或者我必须使用openssl动态加密按钮?或者还有另一种方式?
答案 0 :(得分:2)
您可以收集所有数据服务器端,并使用cURL将数据发布到PayPal,而不是直接发布到PayPal。表格看起来更像是:
<?php
$bizName = isset($_POST['business']):$_POST['business']:"";
$itemNumber = isset($_POST['item_number'])?intval($_POST['item_number']):"";
// Lookup details for the Item, purchase, and collect them into an array maybe
$itemDetails = array(
"cmd" => "_xclick",
"amount" => $itemPrice, // Get from DB
"no_note" => 1,
"currency_code" => "USD",
"bn" => "PP-BuyNowBF",
"business" => $bizName,
"item_name" => $itemName, // Get from DB
"item_number" => $itemNumber
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.paypal.com/cgi-bin/webscr");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($itemDetails));
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$svr_out = curl_exec ($ch);
curl_close ($ch);
// Do something with $svr_out, maybe display it, or if it's a redirect, redirect the user in turn.
?>
然后confirm.php会做一些事情。查找价格,计算总数等。
local composer = require ( "composer")
local scene = composer.newScene()
local function showScene2()
local options = {
effect = "slideLeft",
time = 130,
}
composer.gotoScene("scene2", options)
end
这是未经测试的,更像是一个让您入门的模板。我相信你的网站更复杂,然后你可以建立起来。这只是你能做的事情的一个例子。