From 917a1a02ef13490788b58ba967044e3abc1e12f5 Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Mon, 10 Aug 2015 16:17:01 +1200 Subject: [PATCH] CRM-16993 avoid fatal when line items are created & then altered to completed --- CRM/Member/Form/Membership.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index 17c4d81bf0..2edfa77186 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -1423,9 +1423,9 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; // if the payment processor returns a contribution_status_id -> use it! if (isset($result['contribution_status_id'])) { - $params['contribution_status_id'] = $result['contribution_status_id']; + $result['payment_status_id'] = $result['contribution_status_id']; } - elseif (isset($result['payment_status_id'])) { + if (isset($result['payment_status_id'])) { // CRM-16737 $result['contribution_status_id'] is deprecated in favour // of payment_status_id as the payment processor only knows whether the payment is complete // not whether payment completes the contribution @@ -1492,6 +1492,10 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; if (!empty($softParams) && empty($paymentParams['is_recur'])) { $membershipParams['soft_credit'] = $softParams; } + if (!empty($paymentParams['is_recur']) && CRM_Utils_Array::value('payment_status_id', $result) == 1) { + // CRM-16993 we have a situation where line items have already been created. + unset($membershipParams['lineItems']); + } $membership = CRM_Member_BAO_Membership::create($membershipParams, $ids); $params['contribution'] = CRM_Utils_Array::value('contribution', $membershipParams); unset($params['lineItems']); -- 2.25.1