CRM-16402 payment processor factory change
authorEileen McNaughton <eileen@fuzion.co.nz>
Wed, 13 May 2015 04:52:04 +0000 (16:52 +1200)
committerEileen McNaughton <eileen@fuzion.co.nz>
Thu, 14 May 2015 22:16:39 +0000 (10:16 +1200)
CRM/Contribute/Form/ContributionBase.php
CRM/Financial/BAO/PaymentProcessor.php
Civi/Payment/System.php

index da26df31e684ef02957bc267253bba92db7768f7..8c88cde1186d18af198c5c38854188540c211b70 100644 (file)
@@ -348,7 +348,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
              if (empty($this->_paymentProcessor) && $paymentProcessorDetail['is_default'] == 1 || (count
                  ($this->_paymentProcessors) == 1)
              ) {
-               $this->_paymentProcessor = $processor;
+               $this->_paymentProcessor = $paymentProcessorDetail;
                $this->assign('paymentProcessor', $this->_paymentProcessor);
              }
            }
index 43b47f30357705d759dd119961c8380eb4d88c19..d43def24b54b845aed0d937c2cf1bb3cefea436f 100644 (file)
@@ -210,6 +210,26 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
     }
   }
 
+  /**
+   * Given a live processor ID get the test id.
+   *
+   * @param int $id
+   *
+   * @return int
+   *   Test payment processor ID.
+   */
+  public static function getTestProcessorId($id) {
+    $liveProcessorName = civicrm_api3('payment_processor', 'getvalue', array(
+      'id' => $id,
+      'return' => 'name',
+    ));
+    return civicrm_api3('payment_processor', 'getvalue', array(
+      'return' => 'id',
+      'name' => $liveProcessorName,
+      'domain_id' => CRM_Core_Config::domainID(),
+    ));
+  }
+
   /**
    * @param $paymentProcessorIDs
    * @param $mode
index 3f10f10484fce602f9d6dbfdb342031f542fce56..f01e56d961bef141b90ca153941007021d868b0b 100644 (file)
@@ -29,7 +29,14 @@ class System {
   }
 
   /**
+   * Starting from the processor as an array retrieve the processor as an object.
+   *
+   * If there is no valid configuration it will not be retrieved.
+   *
    * @param array $processor
+   *
+   * @return CRM_Core_Payment|NULL
+   *
    * @throws \CRM_Core_Exception
    */
   public function getByProcessor($processor) {