I am creating a paypal button on my site and would like to get/post a variable to the success url. Here is my code so far:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="GFFJUC8YBXTSHQ3">
<table>
<tr><td><input type="hidden" name="on0" value="Credits">Credits</td></tr>
<tr><td>
<select name="os0">
<option value="5 Credits">5 Credits £5.00 GBP</option>
<option value="10 Credits">10 Credits £10.00 GBP</option>
<option value="20 Credits">20 Credits £20.00 GBP</option>
<option value="50 Credits">50 Credits £50.00 GBP</option>
<option value="TEST">TEST £0.01 GBP</option>
</select>
</td></tr>
</table>
<input type="hidden" name="rm" value="2">
<input type="hidden" name="item_number" value="<?php echo $_REQUEST['os0']; ?>" />
<input type="hidden" name="amount" value="<?php echo $_POST['os0']; ?>" />
<input type="hidden" name="return" value="http://example.com/?order_status=success&value=<?php echo $_REQUEST['os0']; ?>">
<input type="hidden" name="currency_code" value="GBP">
<input type="image" src="http://example.com/buynow.jpg" 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>
But for some reason the value variable returns empty, and get a lot of other variables. here is the success url returned:
?order_status=success&value=&tx=92680583NA758023W&st=Completed&amt=0%2e01&cc=GBP&cm=&item_number=
Any ideas what is going on, and why the value variable is null?
'return' function is actually the URL to which PayPal redirects buyers' browser after they complete their payments. For example, specify a URL on your site that displays a "Thank you for your payment" page. PayPal redirects the browser to a PayPal webpage by default.
If you want to would like to get/post a variable to the success url, you can use PayPal IPN function to get/post transaction details to your URL. Please refer to the link below for the details.
https://developer.paypal.com/docs/classic/products/instant-payment-notification/