1

I'm working with @wmortada debugging some recurring contribution membership renewal issues.

We have lots of memberships with recurring contributions but some of the memberships are not updating as expected when the recurring contribution is received.

The memberships that were not updating were not linked to the recurring contributions via the civicrm_membership.contribution_recur_id field. So we added recurring contribution the link manually. My assumption was that when a contribution for a recurring contribution linked to a membership in this way is received, it would be linked to the membership. But this is not happening for those where we added the field manually.

As a result (as I understand it) CRM_Contribute_BAO_Contribution::updateMembershipBasedOnCompletionOfContribution() is unable to find the related membership and update the membership end date.

We are using @artfulrobot's GoCardless extension for the recurring contribution. CRM_GoCardless_Page_Webhook::doPaymentsConfirmed() calls civicrm_api3('Contribution', 'repeattransaction', $contribution); passing in params for a contribution linked to the recurring contribution.

Can anyone point me to the code that adds a membership payment for a contribution created by Contribution.repeattransaction. Or do I have the wrong end of the stick?

1

2 Answers 2

3

You should make sure that you have both membership_payment records and the contribution_recur_id set for both the contribution and the membership. There are still too many different code paths that can behave slightly differently - it's an area that's seen a lot of improvement but still has a long way to go.

CRM_Member_BAO_Membership::recordMembershipContribution() is an example of a function that creates a membership_payment.

Note that completetransaction should only ever be called for the first contribution. Subsequent payments should call Contribution.repeattransaction API.

Also of relevance is CRM_Contribute_BAO_ContributionRecur::getTemplateContribution() which controls how the next contribution is created - so if that returns a contribution that is not linked to a membership you won't get a membership renewal.

3
  • "Note that completetransaction should only ever be called for the first contribution. Subsequent payments should call Contribution.repeattransaction API." Sorry - that was my typo. It is calling repeattransaction. Mar 31, 2020 at 18:14
  • "You should make sure that you have both membership_payment records and the contribution_recur_id set for both the contribution and the membership." Yes - that is what I am trying to do :) Mar 31, 2020 at 18:15
  • "Also of relevance is CRM_Contribute_BAO_ContributionRecur::getTemplateContribution() which controls how the next contribution is created". Intriguing! I will investigate. Mar 31, 2020 at 18:18
2

Unfortunately CiviCRM doesn't look for civicrm_membership.contribution_recur_id t update the membership. I believe for membership to get auto renewed it should have

  1. The latest recurring contribution for the membership should be linked via civicrm_membership_payment

  2. civicrm_line_item.contribution_id should be set for the membership (the latest one)

Since you had added membership to the standalone recurring contribution than you need to make sure that above 2 step is fixed before next subsequent payment is recorded.

1
  • Thanks Pradeep. I will take a look at the civicrm_line_item table. Mar 31, 2020 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.