Reputation: 3365
The users can pick one of the options from dropdown and pay for it (same cost for all options). The return URL in website preferences is set properly and I do get transaction info as _POST data. The assessments below is a drop-down with few options, how do I pass it paypal and get it back? I tried naming the variable as custom but that didn't work either. What am I doing wrong?
<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>
Upvotes: 1
Views: 3518
Reputation: 3365
Here is the code that worked.
<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>
Upvotes: 1
Reputation: 28
Paypal only accepts the variables mentioned in hidden. Here is the following from Paypal website:
HTML input variables in a PayPal PayPal Payments Standard FORM are always hidden from the payer's view. They have the following general format:
Please check this link: https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/formbasics/
Upvotes: 1