问题
I'm doing simple Paypal payment integration in ASP.NET app., I tried to build the returning query string for both success & cancel but it doesn't work because I'm sending more than one parameter in the querystring
string returnUrl = ConfigurationManager.AppSettings["PayPalSandBoxUrl"] + "&business=" + email;
returnUrl += "&amount= 100";
returnUrl += "&item_name=Invoice to somebody";
// the problem goes in following params
returnUrl += "&return=" + ConfigurationManager.AppSettings["Domain"] + "Payment.aspx?param1=" + param1 + "¶m2=" + param2 ;
returnUrl += "&cancel_return=" + ConfigurationManager.AppSettings["Domain"] + "Payment.aspx?cancel=true¶m1=" + param1;
I think it gets some confusion between paypal request parameters and the return query parameters , is there any solution for this ??
回答1:
When you add on the URL parameters that contains symbols that can confuse the real parametres, symbols as ?
, &
, /
etc, you must encode them with the UrlEncode
So make your string as:
string returnUrl =
ConfigurationManager.AppSettings["PayPalSandBoxUrl"]
+ "&business=" + HttpServerUtility.UrlEncode(email);
returnUrl += "&amount= 100";
returnUrl += "&item_name=" + HttpServerUtility.UrlEncode("Invoice to somebody");
// the problem goes in following params
returnUrl += "&return="
+ HttpServerUtility.UrlEncode(ConfigurationManager.AppSettings["Domain"] + "Payment.aspx?param1=" + param1 + "¶m2=" + param2) ;
returnUrl += "&cancel_return="
+ HttpServerUtility.UrlEncode(ConfigurationManager.AppSettings["Domain"] + "Payment.aspx?cancel=true¶m1=" + param1 );
来源:https://stackoverflow.com/questions/15322148/paypal-multi-parameters-in-return-cancel-return-urls