+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
+ | Copyright CiviCRM LLC (c) 2004-2016 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
+ * @copyright CiviCRM LLC (c) 2004-2016
*/
/**
* @throws Exception
*/
public static function create($params) {
- // FIXME Reconcile with CRM_Admin_Form_PaymentProcessor::updatePaymentProcessor
$processor = new CRM_Financial_DAO_PaymentProcessor();
$processor->copyValues($params);
);
CRM_Financial_BAO_FinancialTypeAccount::add($values);
}
+
Civi\Payment\System::singleton()->flushProcessors();
return $processor;
}
public static function getPaymentProcessors($capabilities = array(), $ids = FALSE) {
$mode = NULL;
$testProcessors = in_array('TestMode', $capabilities) ? self::getAllPaymentProcessors('test') : array();
- $processors = $liveProcessors = self::getAllPaymentProcessors('all');
-
- if (in_array('TestMode', $capabilities)) {
- if ($ids) {
- foreach ($testProcessors as $testProcessor) {
- if (!in_array($testProcessor['id'], $ids)) {
- foreach ($liveProcessors as $liveProcessor) {
- if ($liveProcessor['name'] == $testProcessor['name']) {
- $ids[] = $testProcessor['id'];
- }
+ $processors = self::getAllPaymentProcessors('all');
+
+ if (in_array('TestMode', $capabilities) && is_array($ids)) {
+ $possibleLiveIDs = array_diff($ids, array_keys($testProcessors));
+ foreach ($possibleLiveIDs as $possibleLiveID) {
+ if (isset($processors[$possibleLiveID]) && ($liveProcessorName = $processors[$possibleLiveID]['name']) != FALSE) {
+ foreach ($testProcessors as $index => $testProcessor) {
+ if ($testProcessor['name'] == $liveProcessorName) {
+ $ids[] = $testProcessor['id'];
}
}
}
}
foreach ($processors as $index => $processor) {
- if ($ids && !in_array($processor['id'], $ids)) {
+ if (is_array($ids) && !in_array($processor['id'], $ids)) {
unset ($processors[$index]);
continue;
}