You are here

function uc_payment_gateways_form in Ubercart 5

Same name and namespace in other branches
  1. 6.2 payment/uc_payment/uc_payment.admin.inc \uc_payment_gateways_form()
4 string references to 'uc_payment_gateways_form'
uc_authorizenet_form_alter in payment/uc_authorizenet/uc_authorizenet.module
Implementation of hook_form_alter().
uc_credit_form_alter in payment/uc_credit/uc_credit.module
Implementation of hook_form_alter().
uc_cybersource_form_alter in payment/uc_cybersource/uc_cybersource.module
Implementation of hook_form_alter().
uc_payment_menu in payment/uc_payment/uc_payment.module
Implementation of hook_menu().

File

payment/uc_payment/uc_payment.module, line 474

Code

function uc_payment_gateways_form() {
  $gateways = _payment_gateway_list();
  $methods = _payment_method_list();
  if (is_array($gateways) && count($gateways) > 0) {
    $form['gateways_info'] = array(
      '#value' => '<div><strong>' . t('Payment gateways') . '</strong><br />' . 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>',
    );
    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),
        '#weight' => -7,
      );

      // Find any additional settings defined in the payment gateway callback.
      if (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);
        }
      }
    }
  }
  return system_settings_form($form);
}