I use pay pal subscriptions on site.
When user pay on pay pal I wait IPN message to save it in database.
Also, after payment user is redirected from pay pal to my site where I must check if IPN message is stored in database, and based on that I do some other stuff ind atabase.
The problem is when user is redirected to site sometimes it happens that IPN message is not there yet so I can't do what I want.
So I was thinking to somehow stop application for three seconds but I never did something like this and I don't know is it good to do.
Is it normal that IPN messages delay a few seconds?
If I say Thread.Sleep(3000)
is it possible to display animated loader in web application in this way?
You can take a look on the paypal ipn overview an will find that you will need a different approach.
"The IPN message service does not assume that all messages will be received by your listener in a timely manner. Because the internet is not 100% reliable, messages can become lost or delayed. To handle the possibility of transmission and receipt delays or failures, the IPN message service implements a retry mechanism that resends messages at various intervals until you acknowledge that the message has successfully been received. Messages may be resent for up to four days after the original message."
"The IPN message service should not be considered a real-time service. Your checkout flow should not wait on an IPN message before it is allowed to complete. If your website waits for an IPN message, checkout processing may be delayed due to system load and become more complicated because of the possibility of retries."
One solution would be not to enable the content until the payment arrives, but as you saw it can take up to four days.
Other solution would be, when you create the subscription via paypal API, you receive a response with the subscription info. (ex. the response at the create_recurring payment profile if you are using recurring payments). After this you could take his word that he will pay and enable the content. (of course there is the possibility that the user can unsubscribe before payment, if it takes too long)