用户可以从下拉列表中选择一个选项并为其付费(所有选项的成本相同)。网站首选项中的返回URL设置正确,我将事务信息作为_POST数据。下面的评估是一个下拉,几乎没有选项,我如何通过PayPal并将其取回?我尝试将变量命名为自定义,但这也不起作用。我做错了什么?
<div class="form-group">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<select class="form-select" id="assessments" name="assessments">
foreach ($choices as $key => $value) {
<option value="'.$key.'">'.$value.'</option>
}
</select>
<input type="hidden" name="rm" value="2">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="TESTBUTTONID">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_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>
</div>
答案 0 :(得分:1)
Paypal只接受隐藏中提到的变量。以下是Paypal网站的以下内容:
PayPal PayPal付款标准表单中的HTML输入变量始终隐藏在付款人的视图中。它们具有以下一般格式:
请检查此链接:https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/formbasics/
答案 1 :(得分:1)
这是有效的代码。
<div class="form-group">
<script type="text/javascript">
function assessmentSelected() {
var e = document.getElementById("assessments");
document.getElementById("custom").value = e.options[e.selectedIndex].value;
}
</script>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<select class="form-select" id="assessments" name="assessments" onchange="assessmentSelected()">
<option value="A1">Assessment One</option>
<option value="A2">Assessment Two</option>
<option value="A3">Assessment Three</option>
</select>
<input type="hidden" id="custom" name="custom" value="A1">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="TESTBUTTONID">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_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>
</div>