On the PayPal site in their PHP code for dealing with the IPN they do some minor checks and then put in some comments as to what to do next.
One of the comments is
// check that txn_id has not been previously processed
Indicating that if it has been processed there is something wrong.
What happens when a payment_status goes from "Pending" to "Completed", it would surely send the same txn_id wouldn't it? How else would you identify the transaction and update the record in the database and what "txn_type" is posted for that specific IPN message?
The IPN has been around for years but still the documentation can be so vague and badly explained in most places. They leave you guessing as to what happens in lots of scenarios instead of explaining in detail.
Any help would be great thanks.