2012-02-24 98 views
1
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> 
<input type="hidden" name="cmd" value="_s-xclick"> 
<input type="hidden" name="hosted_button_id" value="YYHZM9FTBZQGW"> 
<input type="hidden" name="amount" value="20.00"> 
<input type="image" src="https://www.sandbox.paypal.com/en_US/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.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> 
</form> 

這是一個paypal沙盒按鈕。我想要做的就是發佈用戶在我的網站上購買的所有產品的總價格。無法在PayPal沙盒中發佈商品價格

我創建了一個沒有任何可發佈的按鈕,因爲基本上我想在將來使用php變量動態發佈,所以我認爲我不需要在沙箱中設置項目價格,名稱,數量創建按鈕功能。我想如何做到這一點。

paypal sandbox

這是輸出。我希望物品價格不能與描述和數量相同

回答

2

您無法動態覆蓋金額的原因是因爲您有所謂的「PayPal託管按鈕」。
使用託管按鈕,金額存儲在PayPal的一端,不能用'金額'變量覆蓋。 您要麼使用非託管按鈕,要麼使用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

我現在明白了,它確實是hosted_id的問題。我開始使用輸入名稱來分支每個細節,我會在我們還有時間的時候實現這個方法。我們的防守將在週四進行,我們仍然有許多模塊落後。謝謝! – 2012-02-26 16:27:59