Donate: Sample HTML button code

DocsLegacyLast updated: January 6th 2022, @ 12:00:51 pm


Important: NVP/SOAP is a legacy integration method. We still provide support, but a newer version of these solutions exists. If you're starting a new integration, we recommend using our Donate SDK.

The following code samples demonstrate various features of PayPal-hosted Donate buttons.

Important: This page contains unencrypted button code for illustrative purposes only. To prevent malicious tampering of buttons on your live website, always encrypt your manually created buttons.

Basic Donate button

The sample HTML code below illustrates a basic Donate button where donors enter their own contribution amount during checkout. The code uses the currency_code variable to set the currency for the contribution amounts that donors enter.

Paste the following code onto your web page below an image or a text description of the item.

<form action="https://www.paypal.com/donate" method="post" target="_top">
 <!-- Identify your business so that you can collect the payments. -->
 <input type="hidden" name="business" value="donations@kcparkfriends.org">
 <!-- Specify details about the contribution -->
 <input type="hidden" name="no_recurring" value="0">
 <input type="hidden" name="item_name" value="Friends of the Park">
 <input type="hidden" name="item_number" value="Fall Cleanup Campaign">
 <input type="hidden" name="currency_code" value="USD">
 <!-- Display the payment button. -->
 <input type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" alt="Donate">
 <img alt="" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>

The sample code above produces the following result:

Donate Button

Fixed contribution amount

The sample HTML code below illustrates a Donate button where the contribution amount that donors make is fixed and cannot be changed. The code uses the amount and the currency_code variables to set fixed contribution amount at $25.00 USD.

Paste the following code onto your web page below an image or a text description of the item.

<form action="https://www.paypal.com/donate" method="post">
 <!-- Identify your business so that you can collect the payments. -->
 <input type="hidden" name="business" value="donations@kcparkfriends.org">
 <!-- Specify details about the contribution -->
 <input type="hidden" name="no_recurring" value="0">
 <input type="hidden" name="item_name" value="Friends of the Park">
 <input type="hidden" name="item_number" value="Fall Cleanup Campaign">
 <input type="hidden" name="amount" value="25.00">
 <input type="hidden" name="currency_code" value="USD">
 <!-- Display the payment button. -->
 <input type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" alt="Donate">
 <img alt="" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >

</form>

You can write your own URL code for Donate email payment links. You can use the same variables and values that you include in HTML Donate buttons.

Important: The example email payment link shown below is included for illustrative purposes only. In a production environment, you should always use a hosted email payment link to prevent malicious users from tampering with the code. Non-hosted email payment links are not secure.

Paste the following code onto your web page below an image or a text description of the item.

https://www.paypal.com/donate?business=donations@kcparkfriends.org&no_recurring=0&item_name=Friends+of+the+Park&item_number=Fall+Cleanup+Campaign&amount=25&currency_code=USD

For information on pasting code, see Copy and paste button code.

See also