I don't know anything about PayPal integration, but is it possible that having the
business=
specified twice is confusing things?
Also, are the values you are including in the
redirectUrl
are appropriately Url encoded? (See
HttpUtility.UrlEncode Method (String) (System.Web)[
^] and/or
HttpUtility.UrlPathEncode Method (String) (System.Web)[
^].)
The code you have is a bit sloppy ;-)
Here's how I'd structure it (I'm not addressing the encoding potential issue.)
Option 1:
const string redirectUrlFormat =
"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business={0}" +
"&first_name=name" +
"&item_name={1}" +
"&amount={2}" +
"&quantity=1" +
"&return={3}"
"&cancel_return={4}";
string redirectUrl = string.Format(redirectUrlFormat,
ConfigurationManager.AppSettings["paypalemail"],
Name, Price,
ConfigurationManager.AppSettings["SuccessURL"],
ConfigurationManager.AppSettings["FailedURL"]);
Response.Redirect(redirectUrl);
Option 2:
StringBuilder redirectUrl = new StringBuilder();
redirectUrl.Add("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business=");
redirectUrl.Add(ConfigurationManager.AppSettings["paypalemail"]);
redirectUrl.Add("&first_name=name&item_name=");
redirectUrl.Add(Name);
redirectUrl.Add("&amount=");
redirectUrl.Add(Price);
redirectUrl.Add("&quantity=1&return=");
redirectUrl.Add(ConfigurationManager.AppSettings["SuccessURL"]);
redirectUrl.Add("&cancel_return=");
redirectUrl.Add(ConfigurationManager.AppSettings["FailedURL"]);
Response.Redirect(redirectUrl.ToString());