Membership not updated if there are multiple recurring contributions
Created by: wmortada
If a member signs up by direct debit more than once it is only the last sign up that is linked to the membership (i.e. the last recurring contribution ID is recorded on the membership record). This can cause a problem if it was the older direct debit that is active because it is no longer linked to the membership. If a payment comes through for this recurring contribution it doesn't update the membership because the extension looks for a membership with a matching recurring contribution ID and there isn't one. This can happen for example if a member signs up twice - the first time completing the process but the second time starting the process but not completing it (the second recurring contribution is created at the point they click confirm on the CiviCRM contribution page so they don't need to type in their bank details in GoCardless for this to be an issue). Obviously this isn't rational behaviour and most of our members don't do this but there are a few that have done this for whatever reason - perhaps they forgot they'd already set up a direct debit or perhaps they received a renewal reminder by mistake.
It's this bit of code that is responsible for this behaviour: https://github.com/artfulrobot/uk.artfulrobot.civicrm.gocardless/blob/master/CRM/GoCardless/Page/Webhook.php#L317-L326
If there was another way of getting the membership ID that might help to fix this issue for this extension. I'm guessing it may be an issue for other payment processors too though. It is a bit of a limitation that CiviCRM only allows one recurring contribution per membership. Ideally it should allow multiple recurring contributions I think - which would mean a change to core.