fix error whereby protected function called
authorEileen McNaughton <eileen@fuzion.co.nz>
Mon, 26 Jan 2015 23:16:55 +0000 (12:16 +1300)
committerEileen McNaughton <eileen@fuzion.co.nz>
Mon, 26 Jan 2015 23:16:55 +0000 (12:16 +1300)
since calling direct payment throws an error we can move the error handling too

CRM/Member/BAO/Membership.php

index 60dc5f196d40d8a4b2f14a100fcb06563998fd93..d19c71e82a738fdd601af708a02c058fc8cb1eb0 100644 (file)
@@ -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;
   }
 
   /**