Paypal multi parameters in return , cancel_return urls

允我心安 提交于 2019-12-12 01:13:26

问题


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


来源:https://stackoverflow.com/questions/15322148/paypal-multi-parameters-in-return-cancel-return-urls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!