X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=Civi%2FPayment%2FSystem.php;h=4150e8b0837c245c2d2557d36c96d9a13dc7480e;hb=a1d4f74491daf9f2b93a3a2f6fec850b05e159ef;hp=e5327240f5caf7952b2ae878812c5cd32983c6f8;hpb=5913f06082d07d21116e2d30a82859a375819ef4;p=civicrm-core.git diff --git a/Civi/Payment/System.php b/Civi/Payment/System.php index e5327240f5..4150e8b083 100644 --- a/Civi/Payment/System.php +++ b/Civi/Payment/System.php @@ -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; } @@ -72,6 +71,34 @@ class System { return $this->cache[$id]; } + /** + * Execute checkConfig() on the payment processor Object. + * This function creates a new instance of the processor object and returns the output of checkConfig + * + * @param array $processor + * + * @return string|NULL + * + * @throws \CRM_Core_Exception + */ + public function checkProcessorConfig($processor) { + $ext = \CRM_Extension_System::singleton()->getMapper(); + if ($ext->isExtensionKey($processor['class_name'])) { + $paymentClass = $ext->keyToClass($processor['class_name'], 'payment'); + require_once $ext->classToPath($paymentClass); + } + else { + $paymentClass = 'CRM_Core_' . $processor['class_name']; + if (empty($paymentClass)) { + 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); + return $processorObject->checkConfig(); + } + /** * Get payment processor by it's ID. *