blog

I like to blog about current software design and development projects, as well as general everyday news and events. I'm passionate about what I do and you can follow my personal journey through my blog. I'm constantly on the lookout for new development techniques and technologies to keep on top of the changing market, so if I do miss anything feel free to leave me a comment.

C#: PayPal Donate Button

If you have a PayPal account and would like to add a donate button to your application you can use the following code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
private void btnDonate_Click(object sender, System.EventArgs e)
{
    string url = "";
 
    string business     = "my@paypalemail.com";  // your paypal email
    string description  = "Donation";            // '%20' represents a space. remember HTML!
    string country      = "AU";                  // AU, US, etc.
    string currency     = "AUD";                 // AUD, USD, etc.
 
    url += "https://www.paypal.com/cgi-bin/webscr" +
        "?cmd=" + "_donations" +
        "&business=" + business +
        "&lc=" + country +
        "&item_name=" + description +
        "&currency_code=" + currency +
        "&bn=" + "PP%2dDonationsBF";
 
    System.Diagnostics.Process.Start(url);
}

Tags: , , , ,

8 Responses to “C#: PayPal Donate Button”

  1. dethknite // September 3rd, 2009 at 6:33 am

    I attempted to use this code but am unable to get it to work. I have tried:
    https://www.paypal.com/en/cgi-bin/webscr” instead, still no luck.

    Just loads up the paypal login screen.

    Help…

  2. Beno Gorancic // September 4th, 2009 at 11:19 am

    Can you show me what your url looks like? Feel free to use the contact page if you don’t want to post it here.

    I have asked another person to test it and also tested it myself just now and I can confirm that it works for me.

  3. Beno Gorancic // September 11th, 2009 at 5:07 pm

    Resolved dethknite’s issue. There was a typo in the URL.

  4. Asimplepersonality // December 17th, 2009 at 10:03 pm

    Thanks man!

    Really useful.

  5. Andyr // August 6th, 2010 at 11:25 pm

    Thanks that worked for me.

  6. profiler26 // September 23rd, 2011 at 11:57 pm

    When i add the button it wont direct me to anything, as far as i ca see i did not forget anything. is it changed maybe for the 2010 version?

  7. Beno Gorancic // September 29th, 2011 at 11:13 am

    It should work. I have just tested it out in 2010 by copy/pasting the above code.

  8. Mitja // April 29th, 2013 at 8:58 pm

    Have you been thinking how to obfuscate this code? If someone opens your app in decompiler, code can be changed (email) and donation can be sent to someone else.

Leave a Reply