Wednesday, July 22, 2009

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

I was trying to test a servlet I wrote to process payapal IPN notifications (my servlet is very similar to the jsp in this example) and even after enabling all the IPN settings in the paypal test account the IPN was not firing at all after the payment, or at least so I thought because my servlet wasn't logging anything.

I then found out that in the sandbox you can thest IPN notifications through the IPN simulator, which also gives you handy error codes in case of failed transactions, such as:

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

Thanks to this I then realized that in my servlet I was only implementing the doGet method but not the doPost. Without the doPost method implemented the servlet won't accept any HTML POSTs, thus the error 405. Implementing the doPost (same code as doGet) method solved the problem.

Morale of the story: Paypal integration can be a bitch.