Paypal sanbox集成 [英] Paypal sanbox integration

查看:58
本文介绍了Paypal sanbox集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过一个例子为ASP.net c#(网站,网络应用程序)一步一步地进行Paypal Sandbox集成吗?



我是什么尝试过:



string redirectUrl =;



redirectUrl + =https ://www.sandbox.paypal.com/cgi-bin/webscr?cmd = _xclick& business =+ ConfigurationManager.AppSettings [paypalemail]。ToString();



redirectUrl + =& first_name = name;



redirectUrl + =& item_name =+ Name;



redirectUrl + =& amount =+ Price;



redirectUrl + =& business = Paypalmail;



redirectUrl + =& quantity = 1;



redirectUrl + =& return = + ConfigurationManager.AppSettings [SuccessURL]。ToString();



redirectUrl + =& cancel_ return =+ ConfigurationManager.AppSettings [FailedURL]。ToString();



Response.Redirect(redirectUrl);





成功URL和失败的URL在Web.config中定义。



此代码重定向到沙箱。但我没有得到回复回复。



有人可以帮忙吗?



提前感谢。

can I have any Paypal Sandbox Integration step by step for ASP.net c# (for Website, web application) with an example?

What I have tried:

string redirectUrl = "";

redirectUrl += "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business=" + ConfigurationManager.AppSettings["paypalemail"].ToString();

redirectUrl += "&first_name=name";

redirectUrl += "&item_name=" + Name;

redirectUrl += "&amount=" + Price;

redirectUrl += "&business=Paypalmail";

redirectUrl += "&quantity=1";

redirectUrl += "&return=" + ConfigurationManager.AppSettings["SuccessURL"].ToString();

redirectUrl += "&cancel_return=" + ConfigurationManager.AppSettings["FailedURL"].ToString();

Response.Redirect(redirectUrl);


Success URL, and Failed URL are defined in Web.config.

this code redirecting to sandbox. but i didnt get return response.

can anyone help on this?

thanks in advance.

推荐答案

我对PayPal集成一无所知,但有可能两次指定 business = 令人困惑的事情?

此外,您在 redirectUrl 中包含的值是否适当地进行了Url编码? (参见 HttpUtility.UrlEncode Method(String)(System.Web) [ ^ ]和/或 HttpUtility.UrlPathEncode方法(字符串)(System.Web) [ ^ ]。)



您所拥有的代码有点草率;-)

以下是我如何构建它(我没有解决编码潜在问题。)

选项1:

I don't know anything about PayPal integration, but is it possible that having the business= specified twice is confusing things?
Also, are the values you are including in the redirectUrl are appropriately Url encoded? (See HttpUtility.UrlEncode Method (String) (System.Web)[^] and/or HttpUtility.UrlPathEncode Method (String) (System.Web)[^].)

The code you have is a bit sloppy ;-)
Here's how I'd structure it (I'm not addressing the encoding potential issue.)
Option 1:
const string redirectUrlFormat = 
"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business={0}" + 
"&first_name=name" +
"&item_name={1}" +
"&amount={2}" +
// "&business=Paypalmail"    // This was the duplication!!!
"&quantity=1" +
"&return={3}"
"&cancel_return={4}";
string redirectUrl = string.Format(redirectUrlFormat,
                                   ConfigurationManager.AppSettings["paypalemail"],
                                   Name, Price,
                                   ConfigurationManager.AppSettings["SuccessURL"],
                                   ConfigurationManager.AppSettings["FailedURL"]);
Response.Redirect(redirectUrl);



选项2:


Option 2:

StringBuilder redirectUrl = new StringBuilder();

redirectUrl.Add("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business=");
redirectUrl.Add(ConfigurationManager.AppSettings["paypalemail"]);
redirectUrl.Add("&first_name=name&item_name=");
redirectUrl.Add(Name);
redirectUrl.Add("&amount=");
redirectUrl.Add(Price);
redirectUrl.Add("&quantity=1&return=");
redirectUrl.Add(ConfigurationManager.AppSettings["SuccessURL"]);
redirectUrl.Add("&cancel_return=");
redirectUrl.Add(ConfigurationManager.AppSettings["FailedURL"]);

Response.Redirect(redirectUrl.ToString());


这篇关于Paypal sanbox集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆