PayPal捐赠表单未传递下拉选项名称至PayPal问题排查
问题原因与解决方案
我一眼就发现问题所在啦——你表单里多了一个空的隐藏输入框,它和下拉菜单的name属性完全重名,这就导致PayPal优先读取了那个空值,直接忽略了下拉菜单选中的组织名称。
具体问题点
看这段冲突的代码:
<input type="hidden" name="item_name"> <!-- 后面跟着你的下拉菜单 --> <select name="item_name"> ...选项内容... </select>
这两个元素都使用item_name作为name属性,浏览器提交表单时,空的隐藏字段会被先发送,PayPal接收到后就会采用这个空值,完全覆盖掉后面下拉菜单的选中值。
修复步骤
直接删掉那个空的隐藏<input type="hidden" name="item_name">字段就可以解决问题!
修复后的核心表单代码如下:
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <!-- If using a Business or Company Logo Graphic, include the "cpp_header_image" variable in your View Cart code. --> <input type="hidden" name="cmd" value="_donations"> <!-- Replace "business" value with your PayPal Email Address or Account ID --> <input type="hidden" name="business" value="testemail@paypal.com"> <!-- 已移除空的item_name隐藏字段 --> <input type="hidden" name="item_number" value="WF-1001"> <input type="hidden" name="tax" value="0"> <input type="hidden" name="no_shipping" value="2"> <input type="hidden" name="lc" value="AU"> <input type="hidden" name="currency_code" value="AUD"> <!-- Replace value with the web page you want the customer to return to after a successful transaction --> <input type="hidden" name="return" value="https://mullumseed.org.au/thankyou"> <!-- Replace value with the web page you want the customer to return to after item cancellation --> <input type="hidden" name="cancel_return" value="https://mullumseed.org.au/cancel"> <input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHosted"> <input type="hidden" name="button_subtype" value="products"> <input type="hidden" name="no_note" value="0"> <input type="hidden" name="cn" value="Add special instructions to the seller:"> <!-- -->Please enter your donation amount: (Example - 10.00)<br><br> <input type="text" name="amount" size="5"> <br><br>Choose Your Organization: <select name="item_name"> <option value="Widget Fund Donation - Byron Shire Chemical Free Landcare" selected>Byron Shire Chemical Free Landcare</option> <option value="Widget Fund Donation - Corem">Corem</option> <option value="Widget Fund Donation - Mullum Seed Inc">Mullum Seed Inc</option> <option value="Widget Fund Donation - Mullum Community Garden">Mullum Community Garden</option> <option value="Widget Fund Donation - Mullum Cares">Mullum Cares</option> <option value="Widget Fund Donation - Mullum Mens Shed">Mullum Mens Shed</option> <option value="Widget Fund Donation - Mullum Food Coop">Mullum Food Coop</option> <option value="Widget Fund Donation - Shara Community Gardens">Shara Community Gardens</option> <option value="Widget Fund Donation - Reforest Now">Reforest Now</option> <option value="Widget Fund Donation - Mullumbimbees">Reforest Now</option> </select> <input type="hidden" name="on1" value="Tax Deductable Email Receipt Requested">Would you like a Tax Deductable Email Receipt? <INPUT NAME="os1" type="radio" value="Yes" checked>Yes <INPUT NAME="os1" type="radio" value="No Thanks">No Thanks<br><br> <!-- --> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_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_US/i/scr/pixel.gif" width="1" height="1"> </form>
修改完成后,你可以测试一下提交流程,下拉菜单选中的组织名称就能正常传递到PayPal的付款页面啦。
内容的提问来源于stack exchange,提问作者Loretta
相关产品推荐
相关产品推荐

