[英]Error while paypal integration
I have tried to integrate paypal sandbox
with my project in asp.net. 我试图将
paypal sandbox
与我在asp.net中的项目集成。
Redirection to paypal sandbox working extremely fine ! 重定向到paypal沙盒工作非常好! You can check out your cart !
你可以查看你的购物车! You can make payment !
你可以付款! But the problem is when paypal set redirection to my Success.aspx page !
但问题是当paypal设置重定向到我的Success.aspx页面!
I got the error as 我得到了错误
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 192.168.0.101:808
I am using stream writer Object ! 我正在使用流编写器对象!
Wait Let me post my code ! 等我让我发布我的代码!
this is page_load even of Success.aspx 这甚至是Success.aspx的page_load
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
// Used parts from https://www.paypaltech.com/PDTGen/
// Visit above URL to auto-generate PDT script
authToken = WebConfigurationManager.AppSettings["PDTToken"];
//read in txn token from querystring
txToken = Request.QueryString.Get("tx");
query = string.Format("cmd=_notify-synch&tx={0}&at={1}", txToken, authToken);
// Create the request back
string url = WebConfigurationManager.AppSettings["PayPalSubmitUrl"];
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
// Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = query.Length;
// Write the request back IPN strings
StreamWriter stOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
stOut.Write(query);
stOut.Close();
// Do the request to PayPal and get the response
StreamReader stIn = new StreamReader(req.GetResponse().GetResponseStream());
strResponse = stIn.ReadToEnd();
stIn.Close();
// sanity check
Label2.Text = strResponse;
// If response was SUCCESS, parse response string and output details
if (strResponse.StartsWith("SUCCESS"))
{
PDTHolder pdt = PDTHolder.Parse(strResponse);
Label1.Text = string.Format("Thank you {0} {1} [{2}] for your payment of {3} {4}!",
pdt.PayerFirstName, pdt.PayerLastName, pdt.PayerEmail, pdt.GrossTotal, pdt.Currency);
}
else
{
Label1.Text = "Oooops, something went wrong...";
}
}
}
This sentence creates error !! 这句话造成错误!!
StreamWriter stOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
These type of exception occurs 发生这些类型的异常
Exception Details: System.Net.Sockets.SocketException:
A connection attempt failed because the connected party did
not properly respond after a period of time,
or established connection failed because connected
host has failed to respond 192.168.0.101:808
First off, do not mix PDT and IPN - just use IPN. 首先,不要混用PDT和IPN - 只需使用IPN。 Go into PayPal admin and make sure that the return URL is NOT set there and that PDT is NOT enabled.
进入PayPal管理员并确保没有在那里设置返回URL并且未启用PDT。
There is an IPN class available online just for this purpose - some more info (Caveat: my own blog post): 有一个IPN课程只是为了这个目的在线提供 - 更多信息(警告:我自己的博客文章):
http://codersbarn.com/?tag=/paypal http://codersbarn.com/?tag=/paypal
http://paypalipnclass.codeplex.com/releases/view/31282 http://paypalipnclass.codeplex.com/releases/view/31282
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.