2011-10-19 56 views
0

我想發送總額由客戶支付<input type="hidden" name="amount" value="{$total}">其中{$total}持有總額(聰明),但當我點擊立即購買貝寶按鈕時,它顯示支付金額爲0.00。 ?什麼是錯我的代碼是:如何發送付款總額到PayPal

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測試它,這是創建一個問題嗎?

+0

看看你生成的HTML。 Smarty/PHP代碼不相關。這也將幫助你縮小問題的範圍。 –

+0

我的smarty代碼有什麼問題? – Nitish

+0

我該怎麼知道? –

回答

3

不能覆蓋的原因動態金額,是因爲你有一個所謂的'貝寶託管按鈕'。
使用託管按鈕,金額存儲在PayPal的一端,不能用'金額'變量覆蓋。 您要麼使用非託管按鈕(如Peter Szymkowski在其答案中使用的那樣),要麼使用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)

使用託管按鈕的原因是因爲它更安全。一個非託管的,未加密的按鈕基本上可以讓這些數據處於開放狀態。等待發生欺詐交易。

0

貝寶量關鍵是amount_1,不amount所以...

<input type="hidden" name="amount_1" value="{$total}"> 

編輯:

這工作非常適合我。

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="platnosci"> 
    <input type="hidden" name="cmd" value="_cart"> 
    <input type="hidden" name="upload" value="1"> 
    <input type="hidden" name="business" value="[email protected]"> 
    <input type="hidden" name="notify_url" value="http://www.google.pl/paypal.php"> 
    <input type="hidden" name="item_name_1" value="Item description"> 
    <input type="hidden" name="amount_1" value="34.00"> 
    <input type="hidden" name="currency_code" value="PLN"> 
    <input type="hidden" name="shopping_url" value="http://www.arest.pl"> 
    <input type="hidden" name="email" value="tester"> 
    <input type="submit"> 
</form> 

確保您{$總}不是空白

+0

其相同....顯示0.00 – Nitish

+0

@Nitish請檢查我的新答案請 – Peter

+0

這是不正確的。它是'amount_1'(和'amount_n'用於任何後續項目),但只適用於'cmd'是_cart。 – Robert

-1

剛剛嘗試這個代碼

<input name=AMT value="{$total}"> 

更正,

<input type="hidden" name="amount" value={$total}> 
+0

我錯了:) – Peter

+0

對不起,此代碼用於PayPal沙盒NVP ** SetExpressCheckout ** –