私はpaypalアプリケーションをテストしようとしていて、paypal notify_urlをwww.xx.com/paypal.aspxとして指定しました。私はサンドボックスのペイパルから応答を得ているはずです。しかし、私はpaypal.aspxページで何も取得していません。私のrepsonse処理コードは次のとおりです。Paypalのnotify_urlページにPaypalレスポンスがないIPN
protected void Page_Load(object sender, EventArgs e)
{
string connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
con = new SqlConnection(connStr);
con.Open();
//Post back to either sandbox or live
string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
// string strLive = "https://www.paypal.com/cgi-bin/webscr";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strSandbox);
//Set values for the request back
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
string strRequest = Encoding.ASCII.GetString(param);
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();
if (strResponse == "VERIFIED")
{
//Insert statement
}
else if (strResponse == "INVALID")
{
//UPDATE YOUR DATABASE
StreamWriter swr = new StreamWriter(Server.MapPath("Textfile.txt"));
swr.WriteLine("---- not verified(" + DateTime.Now.ToString() + ")--");
swr.Dispose();
}
else
{ //UPDATE YOUR DATABASE
//TextWriter txWriter = new StreamWriter(Server.MapPath("../uploads/") + Session["orderID"].ToString() + ".txt");
//txWriter.WriteLine("Invalid");
////log response/ipn data for manual investigation
//txWriter.Close();
}
支払いは完全に処理されます。私はまた、ありがとうございますページに指示されています。あなたはnotify_url値としてPayPalに渡しているURLが公に有効で解決可能URLであることを確認する必要があり、
最初にデータベースが開いていて、それを使用して閉じてください。とにかくここにはなぜそれがありますか? 2番目に実際にこのコードの問題は何ですか?あなたはあなたがpaypalに送るURLにすべての問題が呼び出されていないと言っているからです。これはどこから呼ばれると思いますか?静的IP上のサーバーからasdn rooterの背後にあるローカルコンピュータから?どこから ? – Aristos
私はデータベース接続を開いています。コードは問題ではない、これは私がIPNの応答を得なければならないページです。しかし、私はちょうどIPNの歴史をチェックし、私の取引は起こっているが、その状態はそこでは失敗している。質問の枠組みが貧弱で残念です。それはサーバーから呼び出されます。 – vini
あなたは間違った方法でデータベースを開き、そのコードを閉じることを忘れてしまいます。今、このページは呼ばれていますか? – Aristos