Paypal Sandbox IPN does not detect Content-type

I have used the past few hours trying to understand why the IPS simulator in Sandbox Sandbox does not detect Content-type on my request. I did not change any code where the request was made, so it is strange that it did not pass correctly.

The question was similar in March, although the answer he noted did not seem to me a trick.

Does anyone know why this is happening? Has this happened to someone else recently?

public class PaypalIPN : IHttpHandler, IRequiresSessionState { public void ProcessRequest (HttpContext context) { //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 = context.Request.BinaryRead(HttpContext.Current.Request.ContentLength); string strRequest = Encoding.ASCII.GetString(param); strRequest += "&cmd=_notify-validate"; req.ContentLength = strRequest.Length; //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(); ... 
0
source share
2 answers

So, using ASHX did not work, but apparently when I switched to the ASPX file, it magically worked. I am not sure if ASHX has what does not make it work, but ASPX was the solution.

0
source

I just ran into the same problem as the implementation of the IPN listener in Play2 (Scala).

Note. The invalid type of your request back to Paypal is that it complains about it, you return its response to the original Paypal IPN request that it provides to your listener.

I returned play.api.mvc.SimpleResult.Ok () (which maps to Http 200), but received the message "IPN not detecting Content-type".

After I scratched my head and made sure I was returning right away, I re-read the documentation and noticed: "Your listener returns the response" HTTP 200 " .

So instead I tried play.api.mvc.SimpleResult.Ok ("") and hey presto it will work!

Therefore, it seems that you should send some content (blank line) with a 200 response for the test service in order to be happy.

0
source

Source: https://habr.com/ru/post/1469393/


All Articles