2014-09-03 113 views
0

我試圖用IPN模擬器測試我的IPN偵聽器,但我總是收到「錯誤請求」錯誤。PayPal IPN模擬器壞請求

從來就已經看到這樣的答案:

PayPal IPN Bad Request 400 Error Paypal SandBox IPN always returns INVALID

對於我的網站I'm使用的代碼,你可以在這裏找到:http://www.markstraley.com/Code/PayPalIPN

在別人的答案思考,也許有在這段代碼中是錯誤的,但我不知道是什麼,如果出現錯誤:

HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);     
webRequest.Method = "POST";     
webRequest.ContentType = "application/x-www-form-urlencoded"; 

//must keep the original intact and pass back to PayPal with a _notify-validate command 
string data = Encoding.ASCII.GetString(parameters);     
data += "&cmd=_notify-validate"; 

webRequest.ContentLength = data.Length;     

//Send the request to PayPal and get the response     
using (StreamWriter streamOut = new StreamWriter(webRequest.GetRequestStream(),System.Text.Encoding.ASCII))     
{      
    streamOut.Write(data);      
    streamOut.Close();     
}  

我以爲在這段代碼中,因爲我看到其他asnwers已經被請求的頭部解決了,但是我不知道這段代碼對於PayPal是否正確。我已經看到了貝寶代碼示例,但所有這些都使用VB或webforms。

謝謝您的幫助。

注:我有我的應用程序在一個服務器來測試它,我不想從IPN模擬器調用我的本地主機。

回答