fix for test payment processors not loading
authoreileenmcnaughton <eileen@fuzion.co.nz>
Mon, 29 Jun 2015 21:16:41 +0000 (21:16 +0000)
committereileenmcnaughton <eileen@fuzion.co.nz>
Mon, 29 Jun 2015 21:16:41 +0000 (21:16 +0000)
CRM/Financial/BAO/PaymentProcessor.php

index edbd08aa5035fd6a18bf5a0fffa2f6f697138ad1..169aab7bc1292d992b9951568b507fbd620018ae 100644 (file)
@@ -362,16 +362,24 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
    */
   public static function getPaymentProcessors($capabilities = array(), $ids = array()) {
     $mode = NULL;
+    $testProcessors = in_array('TestMode', $capabilities) ? self::getAllPaymentProcessors('test') : array();
+    $processors = $liveProcessors = self::getAllPaymentProcessors('live');
+
     if (in_array('TestMode', $capabilities)) {
-      $mode = 'test';
-    }
-    elseif (in_array('LiveMode', $capabilities)) {
-      $mode = 'live';
+      foreach ($testProcessors as $testProcessor) {
+        if (!in_array($testProcessor['id'], $ids)) {
+          foreach ($liveProcessors as $liveProcessor) {
+            if ($liveProcessor['name'] == $testProcessor['name']) {
+              $ids[] = $testProcessor['id'];
+            }
+          }
+        }
+      }
+      $processors = $testProcessors;
     }
-    $processors = self::getAllPaymentProcessors($mode);
 
     foreach ($processors as $index => $processor) {
-      if (!empty($ids) && !in_array($processor['id'], $ids)) {
+      if (!in_array($processor['id'], $ids)) {
         unset ($processors[$index]);
         continue;
       }