Merge pull request #12969 from christianwach/issue-460
[civicrm-core.git] / Civi / Payment / System.php
index 2ba7083c41e20487fade8a99269709a47b6d7a41..4150e8b0837c245c2d2557d36c96d9a13dc7480e 100644 (file)
@@ -53,18 +53,17 @@ class System {
       }
       else {
         $paymentClass = 'CRM_Core_' . $processor['class_name'];
-        if (empty($paymentClass)) {
+        if (empty($processor['class_name'])) {
           throw new \CRM_Core_Exception('no class provided');
         }
-        require_once str_replace('_', DIRECTORY_SEPARATOR, $paymentClass) . '.php';
       }
 
-      $processorObject = new $paymentClass(!empty($processor['is_test']) ? 'test' : 'live', $processor);
-      if (!$force && $processorObject->checkConfig()) {
-        $processorObject = NULL;
-      }
-      else {
-        $processorObject->setPaymentProcessor($processor);
+      $processorObject = NULL;
+      if (class_exists($paymentClass)) {
+        $processorObject = new $paymentClass(!empty($processor['is_test']) ? 'test' : 'live', $processor);
+        if ($force || !$processorObject->checkConfig()) {
+          $processorObject->setPaymentProcessor($processor);
+        }
       }
       $this->cache[$id] = $processorObject;
     }