我在 ASP.NET 应用程序中进行简单的 Paypal 支付集成,我尝试为成功和取消构建返回查询字符串,但它不起作用,因为我在查询字符串中发送了多个参数
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;
我认为 paypal 请求参数和返回查询参数之间有些混淆,对此有什么解决方案吗??
最佳答案
当您在 URL 参数上添加包含可能混淆真实参数的符号时,如 ?
、&
、/
等符号,你必须用 UrlEncode 对它们进行编码
所以让你的字符串为:
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 );
关于asp.net - Paypal 多参数返回,cancel_return urls,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15322148/