'class_name' => 'Payment_Manual',
'name' => 'pay_later',
'billing_mode' => '',
+ 'is_default' => 0,
+ // This should ideally be retrieved from the DB but existing default is check so we'll code that for now.
+ 'payment_instrument_id' => CRM_Core_OptionGroup::getValue('payment_instrument', 'Check', 'name'),
// Making this optionally recur would give lots of options -but it should
// be a row in the payment processor table before we do that.
'is_recur' => FALSE,
public static function getPaymentProcessors($capabilities = array(), $ids = FALSE) {
$mode = NULL;
$testProcessors = in_array('TestMode', $capabilities) ? self::getAllPaymentProcessors('test') : array();
- $processors = $liveProcessors = self::getAllPaymentProcessors('all');
+ $processors = 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'];
- }
+ $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;
}