1
votes

I saw several examples of implementing the Paypal IPN protocol in PHP, like https://github.com/paypal/ipn-code-samples/blob/master/IPN_PHP.txt. It works fine. Nevertheless I have a doubt that bothers me.

The documentation on https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNIntro/ says:

...
2. PayPal HTTP POSTs your listener an IPN message that notifies you of this event.
3. Your listener returns an empty HTTP 200 response.
4. Your listener HTTP POSTs the complete, unaltered message back to PayPal.
...

In the examples I've seen step 3 is skipped and 4 is done right after 2. Why is that?

2
You might want to check standard examples that had implemented Paypal IPN protocol exactly the say way as per paypal developer documents. Are you sure that you are referring to the recommended examples on net?thatzprem
The following URL is recommended by Paypal github.com/paypal/ipn-code-samples/blob/master/IPN_PHP.txt and indeed it is in the official paypal github project, so I guess this are recommended examples. I cannot see that they do step 2 there. Also if I try to execute the example code using the IPN simulator and do an ngrep I cannot see the empty 200 response being send. On the other hand everything seems to work fine, since I complete all other steps successfully.finrod

2 Answers

1
votes

An 200 is the default response of a PHP script. You don't have to send it, you just have to make sure you don't send anything else!

Similarly for empty: if you don't do an echo then your response will be empty.

-1
votes

But I saw it here: https://developer.paypal.com/webapps/developer/docs/classic/ipn/gs_IPN/

<?php

   // Send an empty HTTP 200 OK response to acknowledge receipt of the notification 
   header('HTTP/1.1 200 OK'); 
   ...