You are here

function uc_payment_gateways_form in Ubercart 6.2

Same name and namespace in other branches
  1. 5 payment/uc_payment/uc_payment.module \uc_payment_gateways_form()

Displays an overview of the available payment gateways.

4 string references to 'uc_payment_gateways_form'
uc_authorizenet_form_alter in payment/uc_authorizenet/uc_authorizenet.module
Implements hook_form_alter().
uc_credit_form_alter in payment/uc_credit/uc_credit.module
Implements hook_form_alter().
uc_cybersource_form_alter in payment/uc_cybersource/uc_cybersource.module
Implements hook_form_alter().
uc_payment_menu in payment/uc_payment/uc_payment.module
Implements hook_menu().

File

payment/uc_payment/uc_payment.admin.inc, line 181
Payment administration menu items.

Code

function uc_payment_gateways_form() {
  $gateways = _payment_gateway_list();
  $methods = _payment_method_list();
  $form = array();
  $form['gateways'] = array(
    '#summary callback' => '_uc_payment_gateways_summarize',
    '#summary arguments' => array(
      $gateways,
    ),
  );
  if (is_array($gateways) && count($gateways) > 0) {
    $form['gateways_info'] = array(
      '#value' => '<div>' . t('Payment gateways are web services that allow you to process various types of payments remotely. The settings forms below are for the payment gateways you have installed. Click a name to expand its options and adjust the settings accordingly.') . '</div>',
      '#weight' => -10,
    );
    foreach ($gateways as $gateway) {
      $form['gateways'][$gateway['id']] = array(
        '#type' => 'fieldset',
        '#title' => t('@gateway_name settings', array(
          '@gateway_name' => $gateway['title'],
        )),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
      );
      $supported_methods = array();
      foreach ($methods as $method) {
        if (isset($gateway[$method['id']]) && function_exists($gateway[$method['id']])) {
          $supported_methods[] = $method['name'];
        }
      }
      $form['gateways'][$gateway['id']]['supported_methods'] = array(
        '#value' => '<div>' . t('This gateway supports the following payment methods:') . '<br />' . implode(',', $supported_methods) . '</div>',
        '#weight' => -10,
      );
      $form['gateways'][$gateway['id']]['uc_pg_' . $gateway['id'] . '_enabled'] = array(
        '#type' => 'checkbox',
        '#title' => t('Enable this payment gateway for use.'),
        '#default_value' => variable_get('uc_pg_' . $gateway['id'] . '_enabled', TRUE),
      );

      // Find any additional settings defined in the payment gateway callback.
      if (isset($gateway['settings']) && function_exists($gateway['settings'])) {
        $gateway_settings = $gateway['settings']();
        if (is_array($gateway_settings)) {
          $form['gateways'][$gateway['id']] = array_merge($form['gateways'][$gateway['id']], $gateway_settings);
        }
      }
    }
  }
  else {
    $form['gateways_info'] = array(
      '#value' => '<div>' . t('Payment gateways are web services that allow you to process various types of payments remotely. No payment gateways are currently enabled. Modules providing payment gateways must first be enabled on the !modules administration page under the "Ubercart - payment" fieldset.', array(
        '!modules' => l(t('Modules'), 'admin/build/modules'),
      )) . '</div>',
      '#weight' => -10,
    );
  }
  return system_settings_form($form);
}