views:

801

answers:

1

I am trying to test a servlet I wrote that processes a payapal IPN notification (my servlet is very similar to this example) - thing is even after enabling all the settings in the test account I am using the IPN notification is not firing at all.

I then found out that apparently in the sandbox the only way to test IPN is through the IPN simulator. I am trying to use it but I am getting:

IPN delivery failed. HTTP error code 405: Method Not Allowed

Does anyone have the slightest clue?

Also I am seeking ANY advice for testing IPN handlers in a straightforward manner since the IPN simulator kind of sucks (any option you pick it resets all the fields and so forth).

Any help appreciated!

+2  A: 

I would check to make sure that your web server is allowing POST requests on your IPN handler URL. In this example, I used the PHP version of the example on the page you linked, and placed the script at /ipn.php.

I then telnet to my server. (replace with your server address)

$ telnet myserver.com 80
Trying myserver.com...
Connected to myserver.com.
Escape character is '^]'.

Paste the following into your telnet session. (replace ipn.php and myserver.com). Add a blank line after the last command.

POST /ipn.php HTTP/1.1
Host: myserver.com
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 0
HTTP/1.1 200 OK

If you don't see a 200 Status, it means your application is not handling POST requests properly, which is a probable cause of the 405 Error.

You should make sure that you implement a doPost() method in your servlet, as well as a doGet().

If you are able to get the requests working from the IPN simulator, and are ready to move on to sandbox testing, make sure that you have the correct Notify URL and that IPN is enabled under the sandbox seller's profile.

Also, make sure that you IPN Handler is logging INVALID requests as well, so that you know if the request was even initiated.

Finally, make sure that the IPN verification URL is set to https://www.sandbox.paypal.com/cgi-bin/webscr in your servlet. (the URL in the example you posted is https://www.paypal.com/cgi-bin/webscr)

sixthgear
Additionally, the IPN simulator is probably the best way to test IPN requests quickly. However, if you build your app with a proper IPN handler, and start testing with sandbox accounts, the IPN requests SHOULD be fired off. Make sure that you enable that feature under the sellers sandbox account.
sixthgear
Also, I don't know much about servlets, but have you implemented a doPost method in yours?http://java.sun.com/developer/onlineTraining/Programming/BasicJava1/servlet.html
sixthgear
Thanks for helping, I believe you're right I only implemented doGet in my servlet - please integrate this in the answer, I'll test and mark as accepted.
JohnIdol
also I did enable the feature under profile Instant Payment Notification but it doesn't seem to be firing at all!
JohnIdol
Added information about doPost(), as well as something else to try to get the sandbox IPNs firing.
sixthgear