65.9K
CodeProject is changing. Read more.
Home

How to add a donation button for a Paypal gateway

Dec 12, 2011

CPOL
viewsIcon

10660

Code to add a donation button for Paypal.

Write the below given code into an HTML file where you want to add a donation button.

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick"/>
    <input type="hidden" name="business" value="donations@example.com"/>
    <input type="hidden" name="item_name" value="School Fund"/>
    <input type="hidden" name="item_number" value="2011"/>
    <input type="hidden" name="amount" value="50.00"/>
    <input type="hidden" name="no_shipping" value="2"/>
    <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="bn" value="PP-DonationsBF"/>
    <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.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>

where input type are fields to have values for your expectations, the name business shows the value for the type of business, item_name shows the type of item, amount for the value of item, and so on ...

And you are done with a button for your Paypal payment gateway.

And for the rest making a change in value for the line <input type="hidden" name="bn" value="PP-DonationsBF"/>,
you can switch between several types of alternatives:

  1. <input type="hidden" name="bn" value="PP-SubscriptionsBF"/>
  2. <input type="hidden" name="bn" value="PP-DonationsBF"/>
  3. <input type="submit" value="PayPal"/>
  4. <input type="hidden" name="bn" value="PP-BuyNowBF"/>
  5. <input type="hidden" name="bn" value="PP-ShopCartBF"/>

Hence your Paypal gateway is ready to face the world of payments.