0
votes

I am working on rails 4 application. I need to give payment options for Donation button.

I need to create radiobutton as well as textbox to enter amount of payment for Donation.

My code is

<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="xxxxxxxxxxx">
<input type="hidden" name="amount" value="">
<input type="hidden" name="currency_code" value="USD">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_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>

Here I enter value of amount field by jQuery (code is not posted) so it is not empty ("").

But on the second step the amount I submit in hidden field is not shown.

I google it some people say one can not enter amount on hosted button means it would be fixed every time.

Some people say create the buy now button reference => https://www.paypal.com/webapps/mpp/get-started/donate-button-text-field

What should I do is it possible with hosted button?

Should I change my code ?

1
How are you defining the value of the button? If you're appending a form like above, surely you can just populate the amount field?Richard Peck
you mean to say How I enter value in amount hidden field ?urjit on rails
No I mean - how do you want to populate that field? It's just an HTML form - surely you can make it visible & populate it either from Rails, or with HTML?Richard Peck
I want to populate with HTML. I am sending request to paypal.com/cgi-bin/webscr here on donation amount field is empty it should be filled with the amount that I passed via hidden field.urjit on rails
YEs - let me explain. You've got an HTML form on your site. Surely you can fill the value="" of your amount element with whatever value you want? My question was how do you wish to determine the value you want to associate with it?Richard Peck

1 Answers

0
votes

Whenever you use the PayPal hosted buttons you can't change the amount related information. Hosted buttons are secure in the terms that nobody can fiddle with the amount. Changes to the amount for hosted buttons can only be done thru account or via API's . If you are implementing a solution where you need to change the amount dynamically you should consider using the clear text button or You can dynamically generate the encrypted using the API's

However the variables related to :address ,cancel/return/image/ipn url ,item name/invoice id/custom/quantity can be overridden by passing the variables for hosted buttons.