It seems to be a common problem (I see a lot of questions about this on the net). My IPN script works perfectly. it does everything it is supposed to, except that it returns a 503 to PayPal instead of a 200. So PayPal keeps resending the IPN. I looked at my server logs and sure enough the page in question returns a 503 when called from PayPal (but when I call it manually by typing the address it doesn't. Despite it being a common problem however I have yet to find the reason why it does this. I know a 503 means "Service Unavailable" but why would a page throw this error while it still executes perfectly? The only reason I can think of in my case is because I use Joomla and my IPN url is www.somedomain.com/index.php?option=x&view=y So in effect I am not calling a physical page; but that shouldn't matter now should it?
I got it working by placing my handler code in a page that can be accessed directly by the IPN (so no use of a query-string). I did multiple tests with PayPals sandbox IPN-tool and found that any URI with a query-string (on a Joomla site at least, I didn't test non-joomla sites) gave me a 503. I re-wrote my handler to work outside of the joomla install as a workaround. I'm not sure how I could backtrace to see where the 503 originates. But frankly I am happy I got it working now and I will see if I can revisit this in my own time once this project is done.