PayPal Donation Button: Adding 'Amount' and 'Currency' - paypal

I have the "normal" PayPal donation button. I want to add two multiple choice fields: Amount and Currency as the image below. So the user dont need to put the amount of the PayPal website:
This is the 'normal paypal donation button code':
<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="XXXXXXXXXXXXX">
<input type="image" src="https://www.paypalobjects.com/es_ES/ES/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal.">
<img alt="" border="0" src="https://www.paypalobjects.com/es_ES/i/scr/pixel.gif" width="1" height="1">
</form>
I have read on this post that you have to add the following lines, but I dont know where or how to do it. It doesnt work.
<label for="amount">Select the amount you wish to donate:</label>
<select name="amount" id="amount">
<option value="5.00">$5.00</option>
<option value="25.00">$25.00</option>
<option value="50.00">$50.00</option>
</select>
Can anyone tell me how to do it correctly? Thanks!

Hosted PayPal buttons allow you to send option variables, but when not for a donation button, be sure that the option values (for drop downs / text boxes) match exactly what is saved in your PayPal account. i.e. do not edit drop down boxes PayPal creates for you.
As for adding drop down boxes / text boxes to a hosted button, perfectly possible, as long as they do not alter the payment amount. So, for creating a hosted donation button that allows you to edit the amount, I advise the following:
Create a buy now button on PayPal, adding the drop down boxes and/or text boxes you wish to add to your donation button. Create this button as if you were creating your donation button, because that is exactly what we will be doing, changing this button into a donation button.
Copy the the whole buy now button HTML code, paste into notepad, or an editor where you can use 'find and replace'.
Replace all occurances of 'buynow' with 'donate' (This usually just changes the image). Also, replace '_xclick' with '_donations'. (to tell PayPal how to generate the checkout page)
You now have a donation button

I had the similar problem, I solved it by the following steps:
Created a basic 'Buy Now' button (without any options or text fields, just the bare button), made sure i unchecked 'save button at PayPal' before clicking 'create button'.
Then After the button is created, and code is generated, clicked 'Remove code protection' on the top-right where the generated code is shown.
added one additional text input with name 'amount'
replaced value _xclick with _donations (on the input field with name='cmd')
the result is the following code, and it works for me (for now) (you need to add some validations though)
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_donations">
<input type="hidden" name="business" value="XXXXXXXXXXXXX">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Sample Name Here">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="cn" value="Add special instructions to the seller:">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynow_LG.gif:NonHosted">
<input type="hidden" name="on0" value="Donate">
<input type="text" name="amount" value="23.00">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

Paypal has specific HTML data requirements when you post to their page.
The 'host_button_id' can only be used for one specific value and it's data that paypal holds on their site as a convenience to their clients.
In order to pass variable data you have to pass all the information they need. The 'host_button_id' is no longer needed.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="herschelgomez#xyzzyu.com">
<label for="amount">Select the amount you wish to donate:</label>
<select name="amount" id="amount">
<option value="5.00">$5.00</option>
<option value="25.00">$25.00</option>
<option value="50.00">$50.00</option>
</select><br/>
<label for="currency_code">Select the currency:</label>
<select name="currency_code" id="currency_code">
<option value="USD">USD</option>
<option value="GBP">GBP</option>
<option value="CAD">CAD</option>
</select><br/>
<input type="hidden" name="currency_code" value="USD">
<input type="image"
src="https://www.paypalobjects.com/es_ES/ES/i/btn/btn_donateCC_LG.gif" border="0"
name="submit" alt="PayPal.">
<img alt="" border="0" src="https://www.paypalobjects.com/es_ES/i/scr/pixel.gif"
width="1" height="1">
</form>
You can find more currency codes here: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_currency_codes
and more html info here: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_buynow_buttons#id08A2G0920QN
Also for the hidden 'cmd' I'm not sure if that will have to change to '_xclick' only. You'll have to test it out and see what works.

Please try this :
<head>
<title>Get Selected Item - DevCurry.com</title>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js">
</script>
<script type="text/javascript" language="javascript">
$(function () {
$('#ddl').change(function () {
$('#divone').text($(this).find(":selected").val());
});
});
</script>
</head>
<body>
<select id="ddl">
<option value="Tomatoes">Tomatoes</option>
<option value="Potatoes">Potatoes</option>
<option value="Onion">Onion</option>
<option value="Olives">Olives</option>
</select>
<br />
<div id="divone" />
<input type="hidden" id="txt" />
</body>
</html>

Related

Passing Donation Amount to PayPal Page

In the past I was able to add a form so a user could add a donation amount on the website and it would send that amount to the PayPal checkout page. It seems that PayPal has changed how this works and I am having issues figuring out how to pass that amount. I am hoping someone here has gotten this to work. Here is my current code and dev site for testing purposes.
<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="VMUWQGHWEATL8" />
<input type="hidden" name="currency_code" value="USD">
<!-- Text Input Boxes -->
<div class="donate-wrapper">
<input type="text" id="amount" name="amount">
<p style="color: #fff">Monthly donation options on the next screen.</p>
<input type="submit" name="submit" value="continue" alt="PayPal - The safer, easier way to pay online!">
</div>
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
</form>
Dev site: https://braindonordev.wpengine.com/support-us/
You can do it. Create a new button via http://www.paypal.com/buttons , and in Step 2 uncheck the option to save the button at PayPal. Then when you have generated your button code, click the option to remove the code protection.
Now you have "unhosted" HTML you can edit.
The unfortunate thing when passing a donation amount is there won't be an option to make the donation recurring, so you would need a separate relabeled "Subscribe" button for that. Relabled meaning, replace the image with one that says "Donate".
Alternatively, just keep the basic Donate button that you have to serve both use cases (recurring and non-recurring). It's intuitive enough, and has a nice big amount box on the next screen and checkbox to make it recurring:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_donations">
<input type="hidden" name="business" value="paypal#redcross.org">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="currency_code" value="USD">
<input type="text" name="amount">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_donateCC_LG.gif:NonHostedGuest">
<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>

Not able to specify "amount" per payment request on PayPal HTMLButton

I am trying to integrate with PayPal using the "HTML Buttons" approach.
The checkout flow is rather simple,
user clicks "Buy Now" -> transferred to PayPal -> payment processed -> returned to the site.
Based on the item that the customer wants to "Buy Now", the "amount" in the submitted form will vary, and I am unable to get PayPal to accept the value I am sending. I always see a text input which is empty when redirected to PayPal.
I tried hosted and unhosted buttons but still not able to see the desired effect.
hosted button HTML example:
<form action="https://www.sandbox.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="HOSTEDBTNVALUE">
<input type="image" src="https://www.sandbox.paypal.com/en_GB/SG/i/btn/btn_buynowCC_LG.gif" name="submit" alt="PayPal – The safer, easier way to pay online!" style="border: 0;">
<img alt="" src="https://www.sandbox.paypal.com/en_GB/i/scr/pixel.gif" style="border: 0; width: 1; height: 1;">
<input type="text" readonly="true" name="item_name" value="Test PayPal integration payment">
<div class="form-group" id="amount_field">
<label class="control-label col-md-2" for="amount">Amount</label>
<div class="col-md-5">
<input type="text" id="amount" name="amount" value="100" aria-describedby="amount_info_0" class="form-control"><span id="amount_info_0" class="help-block">Real</span></div>
</div>
<div class="form-group" id="txnRef_field">
<label class="control-label col-md-2" for="txnRef">Transaction Ref</label>
<div class="col-md-5">
<input type="text" id="txnRef" name="txnRef" value="8d724ad470af4d9d91d49f84068c4bab" aria-describedby="txnRef_info_0" class="form-control"><span id="txnRef_info_0" class="help-block">Required</span></div>
</div>
<input type="hidden" name="currency_code" value="SGD">
</form>
The "amount" above is a text input at the moment because this is my integration testing page, in the actual application it will be a hidden/readonly input embedded in the form.
Here is the unhosted button example code:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----ReallyLongKey-----END PKCS7-----">
<input type="image" src="https://www.sandbox.paypal.com/en_GB/SG/i/btn/btn_buynowCC_LG.gif" name="submit" alt="PayPal – The safer, easier way to pay online!" style="border: 0;"><img alt="" src="https://www.sandbox.paypal.com/en_GB/i/scr/pixel.gif" style="border: 0; width: 1; height: 1;">
<input type="hidden" name="notify_url" value="https://myapplication.com/transaction/paypal/status">
<input type="hidden" name="currency_code" value="SGD">
<input type="hidden" name="custom" value="ad4a63e2f2f04b908ddb8e7c67f9c67a">
<input type="text" readonly="true" name="item_name" value="Test PayPal integration payment">
<div class="form-group" id="amount_field">
<label class="control-label col-md-2" for="amount">Amount</label>
<div class="col-md-5">
<input type="text" id="amount" name="amount" value="100" aria-describedby="amount_info_0" class="form-control"><span id="amount_info_0" class="help-block">Real</span></div>
</div>
<div class="form-group" id="txnRef_field">
<label class="control-label col-md-2" for="txnRef">Transaction Ref</label>
<div class="col-md-5">
<input type="text" id="txnRef" name="txnRef" value="ad4a63e2f2f04b908ddb8e7c67f9c67a" aria-describedby="txnRef_info_0" class="form-control"><span id="txnRef_info_0" class="help-block">Required</span></div>
</div>
</form>
I have screenshots below for the application page and what I see as a result on the PayPal payment page. Please excuse the lack of alignment and styling. This is meant to be a proof of concept before it is pretty.
my application test page for integration
paypal page where amount is expected to be fixed based on my request and not editable.
Not sure what I'm doing wrong here. Please help.
thanks.
I was able to get it going by making PayPal generate the button with the following settings:
1. Merchant account IDs: Use my primary email address [did not use secure merchant account ID]
2. unchecking the save button at PayPal checkbox. Also, in the html button generation interface, I clicked the link remove code protection which made the cmd value from _s-xclick to _xclick

PayPal custom button with dynamic price

I have a website that offers a service where the price changes dynamically. For instance there are radio buttons and checkboxes that make the final price variate. At the final stage I have an hidden input that contains the final price.
How do I tell PayPal that that is the price to charge? I have tried to follow the documentations on PayPal website but I can't find an answer for this.
How could I dynamically change the values of these inputs but also make sure it's safe?
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="herschelgomez#xyzzyu.com">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="Hot Sauce-12 oz. Bottle">
<input type="hidden" name="amount" value="5.95">
<input type="hidden" name="currency_code" value="USD">
<!-- Prompt buyers to enter their desired quantities. -->
<input type="hidden" name="undefined_quantity" value="1">
<!-- Display the payment button. -->
<input type="image" name="submit" border="0"
src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif"
alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1"
src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>
Any help would be much appreciated, I'm really stuck on this.
Thanks,
Jeff

choose amount from dropdown list - paypal

I used the following code for my Donate button. When I choose amount in dropdown list and click Donate. It redirects to paypal site and asking me to enter the amount again but I already chosen amount in the dropdown list. Any help is appreciated. thanks.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<select name="amount" id="amount">
<option value="10">10 SEK</option>
<option value="20">20 SEK</option>
<option value="30">30 SEK</option>
<option value="40">40 SEK</option>
<option value="50">50 SEK</option>
</select>
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="xxxxxxx">
<input type="hidden" name="currency_code" id="currency_code" value="SEK">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_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>
When using hosted PayPal buttons you'll need to configure the drop down options in the button creation wizard. If you want to include all of that on your own you'll need to use non-hosted buttons.

Cannot get Paypal subscribe button to work

I am trying to implement a simple subscribe button using Paypal.
I have used their button generator and then copy pasted that code into my webpage.
The form looks perfectly fine and when I select a package and then click subscribe I need to login to Paypal which also works but then I get this error:
The link you used to access the PayPal system is invalid. Check the link and try again.
This is my button code. What is wrong?
<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="XXXXXX">
<table>
<tr><td><input type="hidden" name="on0" value="Packages">Packages</td></tr><tr><td><select name="os0">
<option value="Donor">Donor: $5,00 USD</option>
<option value="Vip">Vip: $10,00 USD</option>
<option value="Svip">Svip: $15,00 USD</option>
<option value="Elite">Elite: $20,00 USD</option>
</select> </td></tr>
<tr><td><input type="hidden" name="on1" value="Minecraft username">Minecraft username</td></tr><tr><td><input type="text" name="os1" maxlength="200"></td></tr>
</table>
<input type="hidden" name="currency_code" value="USD">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribe_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/sv_SE/i/scr/pixel.gif" width="1" height="1">
</form>
Forgot to fill in all settings for my Paypal Company account. Works fine now with above code.