Get value from html field for payment amount

Singer-1
Contributor
Contributor

As a new user of PayPal I have a question relating to a form value being passed to the PayPal button for submission. I have an html form with a field for the user to input the amount of their donation. What I was wondering if if is possible for me to have that fields amount to be passed to the PayPal button. I do understand variables and saw that there was the ability to use them. If this is possible can I get a detailed description as to how this is done? The field name is: 'donationAmt'. Thank you.

Login to Me Too
1 ACCEPTED SOLUTION

Accepted Solutions
Solved

Quandary
Advisor
Advisor

You would need to the PayPal HTML variables.  There's ton of info here.   The variable you need to use is "amount".   Note, you cannot include any currency symbols as the Checkout Screen will error - for examle, if you enter $5.00, it won't work however 5.00 will.   Below is a basic Donation example that demonstrates how to enter an amount on your web page.  Just replace the "business" variable value with your PayPal email address or your Merchant ID.  Copy the code to a blank page, you can even use Notepad, save the file as Test.html and then you can open it with your browser, enter an amount and there you go.

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>

<head>
  <title></title>
</head>

<body>

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="your email address">
<input type="hidden" name="item_name" value="Special Event">
<input type="hidden" name="item_number" value="SE-001">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://www.mysite.com/thankyou.html">
<input type="hidden" name="cancel_return" value="http://www.mysite.com/cancel.html">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="tax" value="0">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-DonationsBF">
Please enter your donation amount:<br>
<input type="text" name="amount" value="">
<br><br>
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" border="0"
 name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>


</body>
</html>

 

View solution in original post

Login to Me Too
3 REPLIES 3
Solved

Quandary
Advisor
Advisor

You would need to the PayPal HTML variables.  There's ton of info here.   The variable you need to use is "amount".   Note, you cannot include any currency symbols as the Checkout Screen will error - for examle, if you enter $5.00, it won't work however 5.00 will.   Below is a basic Donation example that demonstrates how to enter an amount on your web page.  Just replace the "business" variable value with your PayPal email address or your Merchant ID.  Copy the code to a blank page, you can even use Notepad, save the file as Test.html and then you can open it with your browser, enter an amount and there you go.

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>

<head>
  <title></title>
</head>

<body>

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="your email address">
<input type="hidden" name="item_name" value="Special Event">
<input type="hidden" name="item_number" value="SE-001">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://www.mysite.com/thankyou.html">
<input type="hidden" name="cancel_return" value="http://www.mysite.com/cancel.html">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="tax" value="0">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-DonationsBF">
Please enter your donation amount:<br>
<input type="text" name="amount" value="">
<br><br>
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" border="0"
 name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>


</body>
</html>

 

Login to Me Too

Singer-1
Contributor
Contributor

Thank you for your solution. In that solution the submission takes the value directly to www.paypal.com/cgi-bin/webscr. The organization would like to have all the donor information sent the treasurer and in that process the submit uses a confirmation.php file to process user input and send to the treasurer. So, is there a way to process the PayPal portion from within the confirmation.php file?

Login to Me Too

Singer-1
Contributor
Contributor

Thank you for the code. I do have a question as to why the "hidden" attribute. Are those fields required and completed when the credit card is verified? Are they required by the API to be in the form?

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.