From dedbf76bcde8e286035b6a2b03df1dff00d54315 Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" Date: Sun, 28 Jul 2019 11:26:57 +0100 Subject: [PATCH] Use a more robust method to check if we've already created a membership payment --- CRM/Member/BAO/Membership.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index e7d3adae812b..2ddab06997f7 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -2492,8 +2492,11 @@ public static function recordMembershipContribution(&$params, $ids = array()) { // store contribution id $params['contribution_id'] = $contribution->id; - //insert payment record for this membership - if (empty($ids['contribution']) || !empty($params['is_recur'])) { + // Create membership payment if it does not already exist + $membershipPayment = civicrm_api3('MembershipPayment', 'get', [ + 'contribution_id' => $contribution->id, + ]); + if (empty($membershipPayment['count'])) { civicrm_api3('MembershipPayment', 'create', [ 'membership_id' => $membershipId, 'contribution_id' => $contribution->id,