Lately I’ve been implementing Instant Payment Notification – great feature provided by PayPal. To be honest it cost me quite some time and a little bit of my dignity. I mean you can read the official guide and play with Instant Payment Notification (IPN) simulator – but in the end it’s back to trials and errors.
So here we go, here are some tips for you, I hope you will find them useful and it will save you some time.
When you receive an IPN notification you obviously have to send it back to paypal for verification (with additional
cmd=_notify-validateoption), don’t forget to escape parameters while you do that (it may depend how you send it, but
URI.escapemay be your friend).
You may receive
txn_typeyou didn’t expect, here a (incomplete) list of possible variables:
What’s more interesting (so to speak) is that you may receive different parameters depending on txn_type – for example if you get
subscr_you can identify your buyer with
subscr_id. On the other hand if you get a
recurring_payment_you will have to use
recurring_payment_id. There are more differences but you will have to debug it yourself – this is just a heads up.
PayPal tends to return a time in some messed up format (like
01:00:00 Jan 11, 2013 PST) that can’t be parsed using regular
Time.parsemethod, instead you have to write your own parser:
1 2 3 4
And thats four simple tips that can save A LOT of time.