Donate: sample HTML button code

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

Important: Buttons created on the Create a PayPal payment button page are automatically secured. However, these samples contain unencrypted button code for illustrative purposes only. In your website production environment, always use encrypted or hosted buttons to prevent malicious tampering. If you're manually creating payment buttons, see Secure your HTML buttons for information on security strategies.

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/cgi-bin/webscr" method="post">

    <!-- Identify your business so that you can collect the payments. -->
    <input type="hidden" name="business"
        value="donations@kcparkfriends.org">

    <!-- Specify a Donate button. -->
    <input type="hidden" name="cmd" value="_donations">

    <!-- Specify details about the contribution -->
    <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/webstatic/en_US/i/btn/png/btn_donate_92x26.png"
    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:

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/cgi-bin/webscr" method="post">

    <!-- Identify your business so that you can collect the payments. -->
    <input type="hidden" name="business"
        value="donations@kcparkfriends.org">

    <!-- Specify a Donate button. -->
    <input type="hidden" name="cmd" value="_donations">

    <!-- Specify details about the contribution -->
    <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/webstatic/en_US/i/btn/png/btn_donate_92x26.png"
    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/cgi-bin/webscr?cmd=_donations&business=donations@kcparkfriends.org&item_name=Friends+of+the+Park&item_number=Fall+Cleanup+Campaign&amount=25%2e00&currency_code=USD

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

See also