我正在尝试使用 <input type="hidden" name="amount" value="{$total}">
发送客户要支付的总金额其中 {$total}
持有总金额(聪明)但是当我点击 Paypal 的立即购买按钮时,它显示要支付的金额为 0.00 。怎么了?我的代码是:
Total :
{$total}
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="SVXVEBF9CH4YU">
<input type="hidden" name="amount" value="{$total}">
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
我正在 localhost
中测试它,这是造成那个问题的原因吗?
您无法动态覆盖金额的原因是因为您有一个所谓的“PayPal 托管按钮”。
使用托管按钮,金额存储在 PayPal 端,不能用“金额”变量覆盖。您要么想要使用非托管按钮(正如 Peter Szymkowski 在他的回答中使用的那样),要么使用 BMUpdateButton动态更新按钮数量的 API 调用。
BMUpdateButton 的示例请求如下所示:
USER=Your API username
PWD=Your API password
SIGNATURE=Your API signature
VERSION=82.0
HOSTEDUBTTONID=The value of <input type="hidden" name="hosted_button_id" value="">
BUTTONTYPE=The type of button. E.g. BUYNOW
BUTTONCODE=The type of code you want to get back. E.g. HOSTED
L_BUTTONVAR0=amount=The new amount with a period as separator
L_BUTTONVAR1=item_name=Optional: a new item name if you wish
同样,您也可以使用 BMCreateButton创建新按钮的 API,或使用 BMButtonSearch用于搜索所有存储的托管按钮列表的 API(例如,自动查找按钮的 hosted_button_id)
使用托管按钮的原因是它更安全。一个非托管、未加密的按钮基本上会使金额容易被操纵。等待发生的欺诈交易。
我是一名优秀的程序员,十分优秀!