If anyone is still having this problem, I found another discussion that lead me to a solution for this problem
https://moodle.org/mod/forum/discuss.php?d=177130
Basically it seems that the error is being caused by the calls to message_send() in the ipn script. If this call fails, it causes the ipn script to fail without returning the 200 OK response that paypal requires. Hence the repeated transaction.
Anyway, I found that if I made the changes suggested in the above thread (see the post by James Snell where he describes the helper function attempt_message_send() ) then the ipn.php script works fine and I don't get the transaction repeated messages anymore
Jim