CRM-16402 remove deprecated PaymentSingleton
authorEileen McNaughton <eileen@fuzion.co.nz>
Sun, 12 Jul 2015 11:08:57 +0000 (23:08 +1200)
committerEileen McNaughton <eileen@fuzion.co.nz>
Sun, 12 Jul 2015 11:08:57 +0000 (23:08 +1200)
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Contribute/Page/UserDashboard.php
CRM/Core/Payment.php
CRM/Core/Payment/AuthorizeNetIPN.php
CRM/Event/Cart/Form/Checkout/Payment.php
CRM/Event/Form/Participant.php
CRM/Event/Form/Registration/Confirm.php
CRM/Event/Form/Registration/Register.php
CRM/Member/BAO/Membership.php

index bcc80a2b3d2ab81c1ea0c06dc53887ca7a6caa8c..1e0d0e9adc40d6c60f27826a3feefbf9e53c560b 100644 (file)
@@ -218,7 +218,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
         CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET'
       );
       if ($rfp) {
-        $payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
+        $payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
         $expressParams = $payment->getPreApprovalDetails($this->get('pre_approval_parameters'));
 
         $this->_params['payer'] = CRM_Utils_Array::value('payer', $expressParams);
@@ -1762,7 +1762,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
         // call postProcess hook before leaving
         $form->postProcessHook();
         // this does not return
-        $payment = CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
+        $payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
         $payment->doTransferCheckout($form->_params, 'contribute');
       }
     }
@@ -1842,7 +1842,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
 
     $result = NULL;
     if ($form->_values['is_monetary'] && !$form->_params['is_pay_later'] && $minimumFee > 0.0) {
-      $payment = CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
+      $payment = $form->_paymentProcessor['object'];
 
       if ($form->_contributeMode == 'express') {
         $result = $payment->doExpressCheckout($tempParams);
index 3d001aa70782a9caa4261d633def7c48f5b6b8df..a6d95f38b3b90f77dcc89f29b395fc8361c6cbeb 100644 (file)
@@ -82,8 +82,6 @@ class CRM_Contribute_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBo
         continue;
       }
 
-      // note that we are passing a CRM_Core_Page object ($this) as if it were a form here:
-      $paymentObject = CRM_Core_Payment::singleton($mode, $paymentProcessor, $this);
 
       require_once 'api/v3/utils.php';
       //@todo calling api functions directly is not supported
index 4ae367fce352f510d495780ea4578e2217841606..b5731feccddaeae4156b83c301927982385144f7 100644 (file)
@@ -71,37 +71,6 @@ abstract class CRM_Core_Payment {
 
   protected $_paymentProcessor;
 
-  /**
-   * Singleton function used to manage this object.
-   *
-   * We will migrate to calling Civi\Payment\System::singleton()->getByProcessor($paymentProcessor)
-   * & Civi\Payment\System::singleton()->getById($paymentProcessor) directly as the main access methods & work
-   * to remove this function all together
-   *
-   * @param string $mode
-   *   The mode of operation: live or test.
-   * @param array $paymentProcessor
-   *   The details of the payment processor being invoked.
-   * @param object $paymentForm
-   *   Deprecated - avoid referring to this if possible. If you have to use it document why as this is scary interaction.
-   * @param bool $force
-   *   Should we force a reload of this payment object.
-   *
-   * @return CRM_Core_Payment
-   * @throws \CRM_Core_Exception
-   */
-  public static function singleton($mode = 'test', &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) {
-    // make sure paymentProcessor is not empty
-    // CRM-7424
-    if (empty($paymentProcessor)) {
-      return CRM_Core_DAO::$_nullObject;
-    }
-    //we use two lines because we can't remove the '&singleton' without risking breakage
-    //of extension classes that extend this one
-    $object = Civi\Payment\System::singleton()->getByProcessor($paymentProcessor);
-    return $object;
-  }
-
   /**
    * Opportunity for the payment processor to override the entire form build.
    *
index 85e3a60b829bc9bfa4c70cb90e9029a13ae267ea..c479e6d298a19d8e0680fcce8ff47fd13afce2f3 100644 (file)
@@ -339,7 +339,7 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr
     $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($ids['paymentProcessor'],
       $input['is_test'] ? 'test' : 'live'
     );
-    $paymentObject = CRM_Core_Payment::singleton($input['is_test'] ? 'test' : 'live', $paymentProcessor);
+    $paymentObject = $paymentProcessor['object'];
 
     if (!$paymentObject->checkMD5($input['MD5_Hash'], $input['trxn_id'], $input['amount'], TRUE)) {
       CRM_Core_Error::debug_log_message("MD5 Verification failed.");
index 8bdd10cf1e25c949c0871a669d37e23ccd8de7a6..bf454ecce957a4ad32e75cabab9a3f9eb0ff324d 100644 (file)
@@ -391,11 +391,6 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart {
     $errors = array();
 
     if ($self->payment_required && empty($self->_submitValues['is_pay_later'])) {
-      $payment = CRM_Core_Payment::singleton($self->_mode, $self->_paymentProcessor, CRM_Core_DAO::$_nullObject);
-      $error = $payment->checkConfig($self->_mode);
-      if ($error) {
-        $errors['_qf_default'] = $error;
-      }
       CRM_Core_Form::validateMandatoryFields($self->_fields, $fields, $errors);
 
       // validate payment instrument values (e.g. credit card number)
@@ -576,7 +571,7 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart {
     $params['ip_address'] = CRM_Utils_System::ipAddress();
     $params['currencyID'] = $config->defaultCurrency;
 
-    $payment = &CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
+    $payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
     CRM_Core_Payment_Form::mapParams($this->_bltID, $params, $params, TRUE);
     $params['month'] = $params['credit_card_exp_date']['M'];
     $params['year'] = $params['credit_card_exp_date']['Y'];
index 1645a8ee525e93dbc580aeb22aac4a5c1e62f702..a3ef71f36bebd8b1ba10bac16b106bc8d4685fc7 100644 (file)
@@ -1187,7 +1187,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       $mapParams = array_merge(array('contact_id' => $contactID), $this->_params);
       CRM_Core_Payment_Form::mapParams($this->_bltID, $mapParams, $paymentParams, TRUE);
 
-      $payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
+      $payment = $this->_paymentProcessor['object'];
 
       // CRM-15622: fix for incorrect contribution.fee_amount
       $paymentParams['fee_amount'] = NULL;
index 11dcbcf4bba10fcf18af515fbcace2ab78fbd373..9d378b464adb7d22915dc19c3235784e1c791a8b 100644 (file)
@@ -90,7 +90,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
 
       //we lost rfp in case of additional participant. So set it explicitly.
       if ($rfp || CRM_Utils_Array::value('additional_participants', $this->_params[0], FALSE)) {
-        $payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
+        $payment = $this->_paymentProcessor['object'];
         $paymentObjError = ts('The system did not record payment details for this payment and so could not process the transaction. Please report this error to the site administrator.');
         if (is_object($payment)) {
           $expressParams = $payment->getExpressCheckoutDetails($this->get('token'));
@@ -580,7 +580,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
       // required only if paid event
       if ($this->_values['event']['is_monetary'] && !($this->_allowWaitlist || $this->_requireApproval)) {
         if (is_array($this->_paymentProcessor)) {
-          $payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
+          $payment = $this->_paymentProcessor['object'];
         }
         $result = NULL;
 
index 44254ac31430d82ee0618e4d30e632bc0a32d4c7..8100e4e7eeb5f65e588a668d92555aa250e015fa 100644 (file)
@@ -1098,7 +1098,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
       $this->set('invoiceID', $invoiceID);
 
       if (is_array($this->_paymentProcessor)) {
-        $payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
+        $payment = $this->_paymentProcessor['object'];
       }
       // default mode is direct
       $this->set('contributeMode', 'direct');
index c8020476f8775f3e3e70c785537e5fe0f3b6b650..e31c841b99a94f6433bff7f3097d47a2929e6291 100644 (file)
@@ -1298,7 +1298,7 @@ AND civicrm_membership.is_test = %2";
         // call postProcess hook before leaving
         $form->postProcessHook();
         // this does not return
-        $payment = CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
+        $payment = $form->_paymentProcessor['object'];
         $payment->doTransferCheckout($form->_params, 'contribute');
       }
     }