How to handle slow IPN response?

1.4k views Asked by At

I have a website which allows users to pay using paypal. I use paypals IPN to find out if the payment was successful or not.

Everything works fine as long as the complete, cancel, pending, failed etc ipn responses are quick. However, I need to stop users from paying more than once if paypal is slow at sending an ipn response.

For example, if paypal is going to send a complete response, in which case it will not send a pending response. If paypal takes 5 minutes to do that. How do I stop users from paying twice within those 5 minutes?

1

There are 1 answers

0
Vlad Preda On BEST ANSWER

This is how I usually use PayPal:

  1. Complete order page, that doesn't contain the PayPal form.
  2. The complete order form redirects to an internal page, that saves the order, and generates the PayPal form. You can do your custom logic here. (ie. check if the user was already sent to PayPal in the last 5 minutes, etc).
  3. The above step should generate the PayPal form with every bit of information that will be sent to Paypal. Note that everything will be hidden from the user, except a submit button. Click that submit button with javascript, so the user will be redirected to PayPal, but as a fallback, do a 5 second timer, and inform the user to click the button if he's not redirected in 5 seconds.

That's it, don't forget to send the order number you saved locally to PayPal in the custom field.

Before proceeding, be aware of the following: If a user is redirected to PayPal - but closes the window, you have no way of knowing if the order will be payed or not. If he clicks cancel, you can send to PayPal a cancel url, where you will receive the information and mark the order as cancelled.

PS:

In step 3 you can tell the user you already have a pending order from them, and they should only proceed if they don't want to pay the previous order.