Search code examples
phppaypal

PayPal Buy-Now button, how to Add my own price?


I have a form that a user fills out prior to reaching the PayPal Buy Now button. The form contains information such as the users name and the amount they will be paying (in a hidden field).

I know there probably is a way to pass the name variable to PayPal using the Advanced Variables feature, but is there a way to alter the buttons price?

And can I do this using PHP variables?

Eg: item_name=<?php $myitem ?>

Any advice would be great!

EDIT: Form as requested

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="XXXX">
<input type="image" src="https://www.paypalobjects.com/en_AU/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.paypalobjects.com/en_AU/i/scr/pixel.gif" width="1" height="1">
</form>

Solution

  • If I understand correctly your question, you have to put the amount hidden field on paypal form. e.g.

    <input type="hidden" name="amount" value="100">
    <input type="hidden" name="currency_code" value="USD">
    

    This form will prompt paypal to ask $100 from buyer.

    of course you can add your own var there e.g.

    <input type="hidden" name="amount" value="<?php echo $amount;?>">
    

    HTH