asp.net - Paypal 多参数返回,cancel_return urls

标签 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 请求参数和返回查询参数之间有些混淆,对此有什么解决方案吗??

最佳答案

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

关于asp.net - Paypal 多参数返回,cancel_return urls,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15322148/

相关文章:

c# - Mootools Scriptmanager Ajax Asp.net 冲突?

c# - 使用 RedirectToAction 方法传递值

ruby-on-rails - ActiveMerchant 支持确定 PayPal Express Checkout 客户/买家的帐户状态(已验证/未验证)

jquery - UpdatePanel 动画仅在超时后运行

asp.net - IIS7上如何获取WEB实例的运行IP地址

iPhone 应用程序和 PayPal

paypal - 我可以使用 PayPal 自动从信用卡中扣款吗?

asp.net - Paypal 响应未出现在 Paypal IPN 的 notify_url 页面上

paypal - 使用 PayPal Adaptive Payments API 获取费用金额?

ruby-on-rails - 具有 Paypal 权限和 Paypal Express Checkout 的 Rails