Paypal repeats identical IPN posts

no_no_no
Contributor
Contributor

Hello,

 

I've noticed PayPal has started to send repeat/duplicate identical IPN posts to my scripts.

 

The initial IPN is sent after payment, then another a few minutes later, and another... and another... up to 3 or 4 days after the intial IPN was received by the scripts.

 

The php scripts do a standard post back to /cgi-bin/webscr?cmd=_notify-validate and the result comes back VERIFIED each time. It's like PayPal is no longer realising that I've called "_notify-validate" so it keeps sending the IPN thinking my script is broken or something.

 

I get a valid answer form paypal like:

 

8
VERIFIED
0

 

My script smoothly run for a few years. But now I have noticed in the paypal ipn documention that paypal expects a "http header 200 OK" after sending the "verified" answer. Is this a new behaviour? Can I simply write a "200 OK" after receiving the answer?

 

fwrite($fp, "200 OK");

 

Regards

no_no_no

Login to Me Too
1 REPLY 1

no_no_no
Contributor
Contributor

I solved it.

 

The problem about all the IPN samples around is the synchronous workflow between the calls:

The IPN request from Paypal to the customers site is a synchronous call that expects an answer within 30 seconds. This is described in the paypal howto...., but there's a significant issue with the samples and the description.

 

Here we go:

1. Paypal sends a request to your script, let's name it ipn_handler:

2. ipn_handler does a synchronous call to paypal's verify_service

3. verify_service answers the call with "verified"

4. ipn_handler _now_ sends a http response back to paypal.

 

So, there are two calls with an answer each:

1-4

2-3

 

On a timeline it is: [1 [2 3] 4].

 

Now the issue. Paypal expects the answer from call [1] within 30 seconds. But paypal needs more then 30 seconds to deliver the answer [3] for call [2]. I messured this more then 10 times.

 

So call [1] never gets a response within 30 seconds. It is impossible, maybe Doc Brown has a solution for this.

 

My workaround. As soon as I saved the request from call [1] in my database I write an HTTP Header "200 OK" to the response-buffer and flush the buffer immediately. So Paypal gets the answer for call [1] right away. After this, the ipn_handler calls the verify_service as designed.

 

Hope this helps it someone is facing the same problem.

Regards,

no_no_no

 

 

 

 

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.