Paypal多参数作为回报,cancel_return网址

时间:2013-03-10 12:20:03

标签: asp.net paypal paypal-sandbox

我在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 + "&param2=" + param2 ;
        returnUrl += "&cancel_return=" + ConfigurationManager.AppSettings["Domain"] + "Payment.aspx?cancel=true&param1=" + param1;

我认为在paypal请求参数和返回查询参数之间会有一些混淆,有没有解决方案?

1 个答案:

答案 0 :(得分:1)

当您添加包含可能会混淆真实参数的符号的URL参数,符号为?&/等时,您必须使用{{3 }}

所以将你的字符串设为:

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 + "&param2=" + param2) ;
        returnUrl += "&cancel_return=" 
          + HttpServerUtility.UrlEncode(ConfigurationManager.AppSettings["Domain"] + "Payment.aspx?cancel=true&param1=" + param1 );