I want to have a donate button on my site. Is there any prebuilt paypal donate buttons stuff? So I just can put it to my site and people can donate money to my site?
NOTICE: Answer to this question is toward the bottom.
I've never created a donate button before, but I have done PayPal standard before on my site. I'd suggest checking out the asp.net control gallery at http://www.asp.net/community/control-gallery/.
Once you're there, just search for "paypal" or "paypal donation"
BTW, paypal donations are pretty easy from what I understand, and I don't think you need a asp server control for them. Is there a reason you're looking for a control instead of just pasting the html you can get from the paypal website:
If you log in under your account, you can go through a wizard that creates a donation button for you. What Paypal Components is handy for is something like payments standard or pro, where you have to process some sort of order fulfillment after payment. With
donations, there's no order fulfillment, so you can just log into your paypal account and see how much money people are giving you.
I've never created a donate button before, but I have done PayPal standard before on my site. I'd suggest checking out the asp.net control gallery at http://www.asp.net/community/control-gallery/.
Once you're there, just search for "paypal" or "paypal donation"
BTW, paypal donations are pretty easy from what I understand, and I don't think you need a asp server control for them. Is there a reason you're looking for a control instead of just pasting the html you can get from the paypal website:
If you log in under your account, you can go through a wizard that creates a donation button for you. What Paypal Components is handy for is something like payments standard or pro, where you have to process some sort of order fulfillment after payment. With
donations, there's no order fulfillment, so you can just log into your paypal account and see how much money people are giving you.
Does that make sense?
--Trevor
Naw I don't really care what it is. I just assumed that it had to be an asp.net control. Whatever gets the job done. I will look into my account and see what I got in there.
I am having problems with there code that it generated. First it complians about validation errors(they are putting border tags in input tags what is apparenlty not allowed).
Also in IE 7 when I put there code in and try to login/logout on my login control it dies. However it works in firefox when I try to login/logout with my login controls.
I get this in IE 7
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback
or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
I'm working on a solution. Hopefully I'll have something for you tonight. As another fix, you could just create a regular html page (or an aspx page without a server-side form), and put the paypal code on that page. Then, from the other pages in your
site, just link to that html page. The problem you're having is because you have two forms on one page -- one server side form (with a runat=server) and one regular form. And .net gets confused with that. :)
You can put all those form variables into a query string (doing a GET submission) and, response.redirect to that query string. For example, from this form that we got on the paypal website:
You'd programmatically make something like this string:
" https://www.paypal.com/us/cgi-bin/webscr?cmd=_xclick&business=me@mybusiness.com&..." Then you'd response.redirect to that url, and paypal would catch all those variables.
Also, make sure that you take at HttpUtility.UrlEncode to make sure that all your values are encoded correctly for use in a url.
The only catch with this is that people can easily tamper with the url string, which in your case isn't a big deal because they're donating to you anyway, so they're not going to try to scam you by changing the prices of any products. If you were going
to use this solution for products that you sell, you'd have to make sure that your IPN catcher validated all the form values (but that's beyond the scope of this question.
Two good resources to get you started using this solution are:
http://www.west-wind.com/presentations/PayPalIntegration/PayPalIntegration.asp#Walkthrough -- good code you can swipe to create a class that assembles the url for you
http://forums.asp.net/p/1224413/2193049.aspx
Solution No. 2
Programmatically create a form, like the one you got from paypal above, and then use javascript to submit it. Like this:
You can put all those form variables into a query string (doing a GET submission) and, response.redirect to that query string. For example, from this form that we got on the paypal website:
You'd programmatically make something like this string:
" https://www.paypal.com/us/cgi-bin/webscr?cmd=_xclick&business=me@mybusiness.com&..." Then you'd response.redirect to that url, and paypal would catch all those variables.
Also, make sure that you take at HttpUtility.UrlEncode to make sure that all your values are encoded correctly for use in a url.
The only catch with this is that people can easily tamper with the url string, which in your case isn't a big deal because they're donating to you anyway, so they're not going to try to scam you by changing the prices of any products. If you were going
to use this solution for products that you sell, you'd have to make sure that your IPN catcher validated all the form values (but that's beyond the scope of this question.
Two good resources to get you started using this solution are:
http://www.west-wind.com/presentations/PayPalIntegration/PayPalIntegration.asp#Walkthrough -- good code you can swipe to create a class that assembles the url for you
http://forums.asp.net/p/1224413/2193049.aspx
Solution No. 2
Programmatically create a form, like the one you got from paypal above, and then use javascript to submit it. Like this:
I'm not a big fan of using javascript for payment stuff, so I'd go with Option 1.
Questions?
Thanks for all you help so far [:D]. I am going to need a lot more though.
I was thinking that was because of a form problem(funny firefox lets it go though).
Now I was hoping this would have been a drag and drop sort of solution but oh well I guess good learning experience.
Now with that said I am stuck. I am read parts of http://www.west-wind.com/presentations/PayPalIntegration/PayPalIntegration.asp#Walkthrough. Some parts I just skipped because lots of this stuff is to do with people actually buying products and I don't
need to concern my self with this at this current point at time.
So I made a test site so I don't have my other code getting in the way.
So far all I done is made an App_Code folder and added .cs file called paypal.cs.
I gone through there code what I thought my be useful but now I am not really sure what to do or what I even have is in the right direction.
So this is what I go:
payPal.cs
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;
/// <summary>
/// Summary description for payPal
/// </summary>
public class payPal
{
public payPal()
{
//
// TODO: Add constructor logic here
//
}
private void HandlePayPalRedirection()
{
// *** Set a flag so we know we redirected to minimize spoofing
Session["PayPal_Redirected"] = "True";
// *** Save the Notes and Types so we can restore them later
Session["PayPal_Notes"] = this.txtNotes.Text;
Session["PayPal_HeardFrom"] = this.txtHeardFrom.Text;
Session["PayPal_ToolUsed"] = this.txtToolUsed.Text;
PayPalHelper PayPal = new PayPalHelper();
PayPal.PayPalBaseUrl = App.Configuration.CCPayPalUrl;
PayPal.AccountEmail = App.Configuration.CCPayPalEmail;
PayPal.LogoUrl = "https://www.west-wind.com/images/wwtoollogo_text.gif";
PayPal.Amount = rowInv.Invtotal;
PayPal.SuccessUrl = Request.Url + "?PayPal=Success";
PayPal.CancelUrl = Request.Url + "?PayPal=Cancel";
Response.Redirect(PayPal.GetSubmitUrl());
return;
}
public string GetSubmitUrl()
{
StringBuilder url = new StringBuilder();
url.Append(this.PayPalBaseUrl + "cmd=_xclick&business=" + HttpUtility.UrlEncode(AccountEmail));
/* not sure if needed */
if (Amount != 0.00M)
{
url.AppendFormat("&amount={0:f2}", Amount);
}
if (LogoUrl != null && LogoUrl != "")
{
url.AppendFormat("&image_url={0}", HttpUtility.UrlEncode(LogoUrl));
}
if (SuccessUrl != null && SuccessUrl != "")
{
url.AppendFormat("&return={0}", HttpUtility.UrlEncode(SuccessUrl));
}
if (CancelUrl != null && CancelUrl != "")
{
url.AppendFormat("&cancel_return={0}", HttpUtility.UrlEncode(CancelUrl));
}
return url.ToString();
}
}
So I am not 100% sure what I go is what I need(since they don't explain everything thing). I am not sure also how I am going to use this? will I make a new object of this class and then link it to a link? or what?
Dude, I am really sorry, but I have totally made it harder that it needs to be for you. Here's what you need to do:
Login to your paypal account.
Go to the merchant services tab (whatever it's called)
Click on create a donate button
Fill in all your information and press submit
You don't need to care about the <form> stuff. Just look at the url that's been created for you. The one for sending with emails. Take that url and in your donate button handler, just call response.redirect(thatURLThatPaypalGaveYou)
That's it. Like I said, I'm really sorry. It'd probably be a good idea if we cleaned up this post a bit so that others who come look at it aren't misguided like I've done to you. Again, I'm sorry. I knew you were doing a donate button, but I kept thinking
you needed to process some sort of input on your end. You don't.
Dude, I am really sorry, but I have totally made it harder that it needs to be for you. Here's what you need to do:
Login to your paypal account.
Go to the merchant services tab (whatever it's called)
Click on create a donate button
Fill in all your information and press submit
You don't need to care about the <form> stuff. Just look at the url that's been created for you. The one for sending with emails. Take that url and in your donate button handler, just call response.redirect(thatURLThatPaypalGaveYou)
That's it. Like I said, I'm really sorry. It'd probably be a good idea if we cleaned up this post a bit so that others who come look at it aren't misguided like I've done to you. Again, I'm sorry. I knew you were doing a donate button, but I kept thinking
you needed to process some sort of input on your end. You don't.
Let me know how this works for you.
--Trevor
Thats alright its good to know that you can do so many things with paypal if I ever need to do something like that.
I just want to be clear though. To get that email link I need to change the Button Encryption right? from encrypted to no enecrypted since I don't see that email thing with encrypted option.?
As with cleaning up. I will leave all the posts how they are and I will just put in my first post at edit statement with these instructions explaining this is for simple donate button and the rest can help you out if you got to do more complex stuff.
Yes, that is right. I actually didn't notice that before, but you are correct. You can't have encrypted buttons this way. Which I said earlier shouldn't be a problem because if you're relying on people's generosity, they probably won't choose to donate
to your site, then scam you out of donating something. That would be silly.
chobo2
Member
16 Points
615 Posts
PayPal donate Plugin for asp.net?
Mar 04, 2008 11:38 PM|LINK
Hi
I want to have a donate button on my site. Is there any prebuilt paypal donate buttons stuff? So I just can put it to my site and people can donate money to my site?
Thanks
T-revor
Member
86 Points
23 Posts
Re: PayPal donate Plugin for asp.net?
Mar 05, 2008 12:34 AM|LINK
NOTICE: Answer to this question is toward the bottom.
I've never created a donate button before, but I have done PayPal standard before on my site. I'd suggest checking out the asp.net control gallery at http://www.asp.net/community/control-gallery/.
Once you're there, just search for "paypal" or "paypal donation"
It seems that Paypal Components might do the trick for you.
BTW, paypal donations are pretty easy from what I understand, and I don't think you need a asp server control for them. Is there a reason you're looking for a control instead of just pasting the html you can get from the paypal website:
https://www.paypal.com/us/cgi-bin/webscr?cmd=_pdn_donate_techview_outside
If you log in under your account, you can go through a wizard that creates a donation button for you. What Paypal Components is handy for is something like payments standard or pro, where you have to process some sort of order fulfillment after payment. With donations, there's no order fulfillment, so you can just log into your paypal account and see how much money people are giving you.
Does that make sense?
--Trevor
chobo2
Member
16 Points
615 Posts
Re: PayPal donate Plugin for asp.net?
Mar 05, 2008 12:44 AM|LINK
Naw I don't really care what it is. I just assumed that it had to be an asp.net control. Whatever gets the job done. I will look into my account and see what I got in there.
Thanks
chobo2
Member
16 Points
615 Posts
Re: PayPal donate Plugin for asp.net?
Mar 05, 2008 01:19 AM|LINK
Hmm
I am having problems with there code that it generated. First it complians about validation errors(they are putting border tags in input tags what is apparenlty not allowed).
Also in IE 7 when I put there code in and try to login/logout on my login control it dies. However it works in firefox when I try to login/logout with my login controls.
I get this in IE 7
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
T-revor
Member
86 Points
23 Posts
Re: PayPal donate Plugin for asp.net?
Mar 05, 2008 01:41 AM|LINK
I'm working on a solution. Hopefully I'll have something for you tonight. As another fix, you could just create a regular html page (or an aspx page without a server-side form), and put the paypal code on that page. Then, from the other pages in your site, just link to that html page. The problem you're having is because you have two forms on one page -- one server side form (with a runat=server) and one regular form. And .net gets confused with that. :)
Don't worry. I'll figure this out.
T-revor
Member
86 Points
23 Posts
Re: PayPal donate Plugin for asp.net?
Mar 05, 2008 03:55 AM|LINK
Ok. So there seem to be two ways of doing this.
Solution No. 1
You can put all those form variables into a query string (doing a GET submission) and, response.redirect to that query string. For example, from this form that we got on the paypal website:
<form name="_xclick" action="https://www.paypal.com/us/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="me@mybusiness.com">
<input type="hidden" name="item_name" value="Team In Training">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="amount" value="25.00">
<input type="image" src="http://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
You'd programmatically make something like this string:
" https://www.paypal.com/us/cgi-bin/webscr?cmd=_xclick&business=me@mybusiness.com&..." Then you'd response.redirect to that url, and paypal would catch all those variables.
Also, make sure that you take at HttpUtility.UrlEncode to make sure that all your values are encoded correctly for use in a url.
The only catch with this is that people can easily tamper with the url string, which in your case isn't a big deal because they're donating to you anyway, so they're not going to try to scam you by changing the prices of any products. If you were going to use this solution for products that you sell, you'd have to make sure that your IPN catcher validated all the form values (but that's beyond the scope of this question.
Two good resources to get you started using this solution are:
http://www.west-wind.com/presentations/PayPalIntegration/PayPalIntegration.asp#Walkthrough -- good code you can swipe to create a class that assembles the url for you
http://forums.asp.net/p/1224413/2193049.aspx
Solution No. 2
Programmatically create a form, like the one you got from paypal above, and then use javascript to submit it. Like this:
http://www.netomatix.com/development/postrequestform.aspx
I'm not a big fan of using javascript for payment stuff, so I'd go with Option 1.
Questions?
chobo2
Member
16 Points
615 Posts
Re: PayPal donate Plugin for asp.net?
Mar 05, 2008 05:46 AM|LINK
Thanks for all you help so far [:D]. I am going to need a lot more though.
I was thinking that was because of a form problem(funny firefox lets it go though).
Now I was hoping this would have been a drag and drop sort of solution but oh well I guess good learning experience.
Now with that said I am stuck. I am read parts of http://www.west-wind.com/presentations/PayPalIntegration/PayPalIntegration.asp#Walkthrough. Some parts I just skipped because lots of this stuff is to do with people actually buying products and I don't need to concern my self with this at this current point at time.
So I made a test site so I don't have my other code getting in the way.
So far all I done is made an App_Code folder and added .cs file called paypal.cs.
I gone through there code what I thought my be useful but now I am not really sure what to do or what I even have is in the right direction.
So this is what I go:
payPal.cs
using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Text; /// <summary> /// Summary description for payPal /// </summary> public class payPal { public payPal() { // // TODO: Add constructor logic here // } private void HandlePayPalRedirection() { // *** Set a flag so we know we redirected to minimize spoofing Session["PayPal_Redirected"] = "True"; // *** Save the Notes and Types so we can restore them later Session["PayPal_Notes"] = this.txtNotes.Text; Session["PayPal_HeardFrom"] = this.txtHeardFrom.Text; Session["PayPal_ToolUsed"] = this.txtToolUsed.Text; PayPalHelper PayPal = new PayPalHelper(); PayPal.PayPalBaseUrl = App.Configuration.CCPayPalUrl; PayPal.AccountEmail = App.Configuration.CCPayPalEmail; PayPal.LogoUrl = "https://www.west-wind.com/images/wwtoollogo_text.gif"; PayPal.Amount = rowInv.Invtotal; PayPal.SuccessUrl = Request.Url + "?PayPal=Success"; PayPal.CancelUrl = Request.Url + "?PayPal=Cancel"; Response.Redirect(PayPal.GetSubmitUrl()); return; } public string GetSubmitUrl() { StringBuilder url = new StringBuilder(); url.Append(this.PayPalBaseUrl + "cmd=_xclick&business=" + HttpUtility.UrlEncode(AccountEmail)); /* not sure if needed */ if (Amount != 0.00M) { url.AppendFormat("&amount={0:f2}", Amount); } if (LogoUrl != null && LogoUrl != "") { url.AppendFormat("&image_url={0}", HttpUtility.UrlEncode(LogoUrl)); } if (SuccessUrl != null && SuccessUrl != "") { url.AppendFormat("&return={0}", HttpUtility.UrlEncode(SuccessUrl)); } if (CancelUrl != null && CancelUrl != "") { url.AppendFormat("&cancel_return={0}", HttpUtility.UrlEncode(CancelUrl)); } return url.ToString(); } }So I am not 100% sure what I go is what I need(since they don't explain everything thing). I am not sure also how I am going to use this? will I make a new object of this class and then link it to a link? or what?T-revor
Member
86 Points
23 Posts
Re: PayPal donate Plugin for asp.net?
Mar 05, 2008 12:12 PM|LINK
Dude, I am really sorry, but I have totally made it harder that it needs to be for you. Here's what you need to do:
Login to your paypal account.
Go to the merchant services tab (whatever it's called)
Click on create a donate button
Fill in all your information and press submit
You don't need to care about the <form> stuff. Just look at the url that's been created for you. The one for sending with emails. Take that url and in your donate button handler, just call response.redirect(thatURLThatPaypalGaveYou)
That's it. Like I said, I'm really sorry. It'd probably be a good idea if we cleaned up this post a bit so that others who come look at it aren't misguided like I've done to you. Again, I'm sorry. I knew you were doing a donate button, but I kept thinking you needed to process some sort of input on your end. You don't.
Let me know how this works for you.
--Trevor
chobo2
Member
16 Points
615 Posts
Re: PayPal donate Plugin for asp.net?
Mar 05, 2008 07:49 PM|LINK
Thats alright its good to know that you can do so many things with paypal if I ever need to do something like that.
I just want to be clear though. To get that email link I need to change the Button Encryption right? from encrypted to no enecrypted since I don't see that email thing with encrypted option.?
As with cleaning up. I will leave all the posts how they are and I will just put in my first post at edit statement with these instructions explaining this is for simple donate button and the rest can help you out if you got to do more complex stuff.
Thanks
T-revor
Member
86 Points
23 Posts
Re: PayPal donate Plugin for asp.net?
Mar 05, 2008 10:39 PM|LINK
Yes, that is right. I actually didn't notice that before, but you are correct. You can't have encrypted buttons this way. Which I said earlier shouldn't be a problem because if you're relying on people's generosity, they probably won't choose to donate to your site, then scam you out of donating something. That would be silly.