그래서 IPN 설명서를 읽었으며 많은 예제를 읽었습니다. 몇 가지 다른 솔루션을 시도해 보았는데 작동하지 않으면 I've simply copy and pasted exactly what is documented on the PayPal IPN page. 이와 같이 여전히 작동하지 않습니다. 내 IPN 기록에 따르면 메시지가 계속 재전송됩니다. 아래 코드 - 누락 된 항목은 무엇입니까?PayPal IPN Listener가 작동하지 않습니다.
protected void Page_Load(object sender, EventArgs e)
{
const string postUrl = "https://www.paypal.com/cgi-bin/webscr";
var req = (HttpWebRequest)WebRequest.Create(postUrl);
//Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
var param = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
var strRequest = Encoding.ASCII.GetString(param);
var ipnPost = strRequest;
strRequest += "&cmd=_notify-validate";
req.ContentLength = strRequest.Length;
//for proxy
//WebProxy proxy = new WebProxy(new Uri("http://url:port#"));
//req.Proxy = proxy;
//Send the request to PayPal and get the response
var streamOut = new StreamWriter(req.GetRequestStream(), Encoding.ASCII);
streamOut.Write(strRequest);
streamOut.Close();
// ReSharper disable AssignNullToNotNullAttribute
var streamIn = new StreamReader(req.GetResponse().GetResponseStream());
// ReSharper restore AssignNullToNotNullAttribute
var strResponse = streamIn.ReadToEnd();
streamIn.Close();
// logging ipn messages... be sure that you give write
// permission to process executing this code
//
if (strResponse == "VERIFIED")
{
//check the payment_status is Completed
//check that txn_id has not been previously processed
//check that receiver_email is your Primary PayPal email
//check that payment_amount/payment_currency are correct
//process payment
var mailer = new Emailer();
mailer.SendMail("[email protected]", "[email protected]", "Thank you!",
"Thank you for your sponsorship. Good luck on your results!<br /><br />" + ipnPost);
}
else if (strResponse == "INVALID")
{
//log for manual investigation
}
}
PayPal 사이트에서 IPN 시뮬레이터로 이동하면 어떤 상태가됩니까? – Paul
"IPN 전달에 실패했습니다. 지정한 URL에 연결할 수 없습니다. URL을 확인한 후 다시 시도하십시오." - 내가 읽은 바로는 PayPal이 리스너의 코드를 좋아하지 않는다는 것을 의미합니다. 샘플에서 제공하는 코드 인 것처럼 이상합니다. – r584