From a19183c1d03df736d6f6939053a0359b9184d813 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 27 Jan 2015 12:16:55 +1300 Subject: [PATCH] fix error whereby protected function called since calling direct payment throws an error we can move the error handling too --- CRM/Member/BAO/Membership.php | 84 +++++++++++++++++------------------ 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index 60dc5f196d..d19c71e82a 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -2214,55 +2214,53 @@ INNER JOIN civicrm_contact contact ON ( contact.id = membership.contact_id AND if ($form->_contributeMode == 'express') { $result = $payment->doExpressCheckout($tempParams); + if (is_a($result, 'CRM_Core_Error')) { + throw new CRM_Core_Exception(CRM_Core_Error::getMessages($result)); + } } else { - $result = $payment->doDirectPayment($tempParams); + $result = $payment->doPayment($tempParams, 'contribute'); } } - if (is_a($result, 'CRM_Core_Error')) { - throw new CRM_Core_Exception(CRM_Core_Error::getMessages($result)); - } - else { - //assign receive date when separate membership payment - //and contribution amount not selected. - if ($form->_amount == 0) { - $now = date('YmdHis'); - $form->_params['receive_date'] = $now; - $receiveDate = CRM_Utils_Date::mysqlToIso($now); - $form->set('params', $form->_params); - $form->assign('receive_date', $receiveDate); - } - - $form->set('membership_trx_id', $result['trxn_id']); - $form->set('membership_amount', $minimumFee); - - $form->assign('membership_trx_id', $result['trxn_id']); - $form->assign('membership_amount', $minimumFee); - - // we don't need to create the user twice, so lets disable cms_create_account - // irrespective of the value, CRM-2888 - $tempParams['cms_create_account'] = 0; - - $pending = $form->_params['is_pay_later'] ? (($minimumFee > 0.0) ? TRUE : FALSE) : FALSE; - - //set this variable as we are not creating pledge for - //separate membership payment contribution. - //so for differentiating membership contribution from - //main contribution. - $form->_params['separate_membership_payment'] = 1; - $membershipContribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, - $tempParams, - $result, - $contactID, - $contributionType, - $pending, - TRUE, - $isTest, - $lineItems - ); - return $membershipContribution; + //assign receive date when separate membership payment + //and contribution amount not selected. + if ($form->_amount == 0) { + $now = date('YmdHis'); + $form->_params['receive_date'] = $now; + $receiveDate = CRM_Utils_Date::mysqlToIso($now); + $form->set('params', $form->_params); + $form->assign('receive_date', $receiveDate); } + + $form->set('membership_trx_id', $result['trxn_id']); + $form->set('membership_amount', $minimumFee); + + $form->assign('membership_trx_id', $result['trxn_id']); + $form->assign('membership_amount', $minimumFee); + + // we don't need to create the user twice, so lets disable cms_create_account + // irrespective of the value, CRM-2888 + $tempParams['cms_create_account'] = 0; + + $pending = $form->_params['is_pay_later'] ? (($minimumFee > 0.0) ? TRUE : FALSE) : FALSE; + + //set this variable as we are not creating pledge for + //separate membership payment contribution. + //so for differentiating membership contribution from + //main contribution. + $form->_params['separate_membership_payment'] = 1; + $membershipContribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form, + $tempParams, + $result, + $contactID, + $contributionType, + $pending, + TRUE, + $isTest, + $lineItems + ); + return $membershipContribution; } /** -- 2.25.1