Der von PayPal bei this reference zur Verfügung gestellte Mustercode widerspricht eindeutig allen Codebeispielen, die ich finden kann. Insbesondere, dass es die "& cmd = _notify-validate" am Anfang und nicht am Ende erfordert.Beispielcode für IPN-Listener ist gemäß den Dokumenten falsch. Ist es?
Der folgende Code besteht den ersten Test, dh er antwortet nur auf die Anforderung im IPN-Simulator. Sobald der Grunt-Code hinzugefügt wurde, bekomme ich nur "IPN wurde nicht gesendet und der Handshake wurde nicht verifiziert. Bitte überprüfen Sie Ihre Informationen." Antwort.
Ich habe den folgenden Code so viel kommentierte erscheint angemessen:
protected void Page_Load(object sender, EventArgs e)
{
mclog.Info("entered PayPalListener Page_Load");
// Commenting out the rest results in a successful handshake etc with the IPN Simulator
string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
// string strLive = "https://www.paypal.com/cgi-bin/webscr";
mclog.Info(string.Format("strSandBox = [{0}]", strSandbox));
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strSandbox);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] param = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
// The following string can have the cmd text at the beginning or end. Both cause the IPN to spit the dummy.
string strRequest = "&cmd=_notify-validate&";
strRequest += Encoding.ASCII.GetString(param);
// "&cmd=_notify-validate";
req.ContentLength = strRequest.Length;
mclog.Info(string.Format("strRequest = [{0}]", strRequest));
//Send the request to PayPal and get the response
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();
mclog.Info(string.Format("strResponse = [{0}]", strResponse));
}
Der Code so nach richtig erscheint viel Suche ich nehme an, es ist etwas, was ich tun muss. Es gibt eine Erwähnung des "Aktivierens" von IPN in meinem "Profil", aber es gibt keine solche Option in den Profilen, die ich in meinem Entwicklerkonto finden kann.
Ich habe seit Tagen versucht und gesucht und die Frustrationslevel sind von der Skala. Wenn Sie einige Vorschläge haben, dann seien Sie bitte so detailliert wie möglich, weil die PayPal-Dokumentation sehr verwirrend ist und es scheint, dass viel früherer guter Rat jetzt veraltet ist.
einige Logging-Ergebnisse sind:
2016-07-15 00:02:29:854 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 entered PayPalListener Page_Load
2016-07-15 00:02:29:854 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 Received
2016-07-15 00:02:29:870 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 strSandBox = [https://www.sandbox.paypal.com/cgi-bin/webscr]
2016-07-15 00:02:29:870 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 strRequest = [payment_type=instant&payment_date=Fri%20Jul%2015%202016%2016%3A32%3A05%20GMT+0930%20%28Cen.%20Australia%20Standard%20Time%29&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&[email protected]&payer_id=TESTBUYERID01&address_name=John%20Smith&address_country=United%20States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San%20Jose&address_street=123%20any%20street&[email protected]&[email protected]&[email protected]&residence_country=US&item_name1=something&item_number1=AK-1234&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=636818821¬ify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AneSo.zKXXEtrcrzCxSU.y9TEUb1A9u2e-FoPLwAA6kE8qMzV0UNUYV5]
2016-07-15 00:02:29:870 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 strRequest = [payment_type=instant&payment_date=Fri%20Jul%2015%202016%2016%3A32%3A05%20GMT+0930%20%28Cen.%20Australia%20Standard%20Time%29&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&[email protected]&payer_id=TESTBUYERID01&address_name=John%20Smith&address_country=United%20States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San%20Jose&address_street=123%20any%20street&[email protected]&[email protected]&[email protected]&residence_country=US&item_name1=something&item_number1=AK-1234&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=636818821¬ify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AneSo.zKXXEtrcrzCxSU.y9TEUb1A9u2e-FoPLwAA6kE8qMzV0UNUYV5&cmd=_notify-validate]
2016-07-15 00:45:09:012 W15 INFO MyPayPal.Global.createMCLog.0 ###################################
2016-07-15 00:45:09:106 W15 INFO MyPayPal.Global.createMCLog.0 MyPayPal v1.0.0.0 Startup
2016-07-15 00:45:12:700 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 entered PayPalListener Page_Load
2016-07-15 00:45:12:715 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 strSandBox = [https://www.sandbox.paypal.com/cgi-bin/webscr]
2016-07-15 00:45:12:778 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 strRequest = [&cmd=_notify-validate&]
2016-07-15 00:45:12:778 W15 INFO MyPayPal.PayPal.PayPalListener.Page_Load.0 strRequest = [&cmd=_notify-validate&payment_type=instant&payment_date=Fri%20Jul%2015%202016%2017%3A14%3A51%20GMT+0930%20%28Cen.%20Australia%20Standard%20Time%29&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&[email protected]&payer_id=TESTBUYERID01&address_name=John%20Smith&address_country=United%20States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San%20Jose&address_street=123%20any%20street&[email protected]&[email protected]&[email protected]&residence_country=US&item_name1=something&item_number1=AK-1234&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=952340474¬ify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31Ag-J5Edcf2.K.Ii9C6RoBck3ltT5]
Ich habe hinzugefügt ServicePointManager.SecurityProtocol = (SecurityProtocolType) 3072; und \t \t \t ServicePointManager.Expect100Continue = true; und bekomme jetzt nur eine "INVALID" Antwort. – David