PayPal Buy Now button: Add my own price?

2019-09-09 23:16发布

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! Thanks

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>

2条回答
唯我独甜
2楼-- · 2019-09-09 23:31

I cannot even get this working with an unhosted button. It seems Paypal never lets you change the amount. I see it like this :

hosted button : amount is set in the code pointed to by the 'hosted button id' unhosted button : PayPal encrypts the information, of which amount is part of

so, in either case you cannot change it, or at least, I haven't been able to do this.

Having said that, there is a variable called 'amount' you can use. So, I'm very confused about this.

查看更多
劫难
3楼-- · 2019-09-09 23:48

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

查看更多
登录 后发表回答