[英]PayPal IPN Sandbox error with asp.net
我對IPN沙箱和ASP.NET 4.0有問題。 我在生產部件中使用的相同代碼不適用於SandBox。
引發的錯誤如下:
異常消息:基礎連接已關閉:發送時發生意外錯誤。
這是代碼:
string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strSandbox);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(param);
string strResponse_copy = strRequest; //Save a copy of the initial info sent by PayPal
strRequest += "&cmd=_notify-validate";
req.ContentLength = strRequest.Length;
StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
streamOut.Write(strRequest);
streamOut.Close();
StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
string strResponse = streamIn.ReadToEnd();
streamIn.Close();
錯誤在網上提出
StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
處理而不是調用付款頁面的代碼可以正常工作。
我該如何解決?
如果相同的代碼在生產站點上有效,但不能在沙盒上運行,則很可能是沙盒環境出現間歇性網絡問題。
最近,我已經看到了此問題以及與沙盒相關的問題。 繼續重試代碼,我相信某些請求會通過,而其他請求會被丟棄。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.