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 + "¤cy_code=" + currency + "&bn=" + "PP%2dDonationsBF"; System.Diagnostics.Process.Start(url); } |
Tags: .Net, C#, Donate, PayPal, Visual Studio
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…
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.
Resolved dethknite’s issue. There was a typo in the URL.
Thanks man!
Really useful.
Thanks that worked for me.
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?
It should work. I have just tested it out in 2010 by copy/pasting the above code.
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.