The patch would pretty much contain the same thing that I posted above. So that is a good start.
1. The way IPN handling is done is somewhat wrong, I think Paypal single transaction IPN structure and recurring transactions IPN structure is not same, hence the issue. Refer to Paypal's IPN documentation for all possible use cases that need to be considered.
2. Also one important thing to note is, the API CreaterecurringPayments used doesnot support the param NOTIFYURL, which means you have to explicitly set it up on your paypal merchant. In all the documents I have seen it was never mentioned, after lots of trail and error and talking to paypal this was identified.
3. Test this without recurring, so we can be sure we did not break ubercart :-)
So anyone loooking to fix it should start by looking into the above points, although as I pointed out above, some of this might fall under ubercart's domain, specifically ubercart - paypal's.
I still did not manage to fix the entire flow,somehow it was not conflicting with the business requirement I had. But few issues that are open are, the order doesn't get updated, the code should Ideally add a order comment to the order with the amount that was charged, but somehow this behavior is not consistent.
I will see if I can manage it this weekend, I am neck deep in stuff right now and on top of that will need to setup a public dummy instance again for testing :-/
Cheers,
Swarad