You are here

function commerce_payment_methods in Commerce Core 7

Returns an array of payment methods defined by enabled modules.

Return value

An associative array of payment method objects keyed by the method_id.

7 calls to commerce_payment_methods()
commerce_payment_default_rules_configuration in modules/payment/commerce_payment.rules_defaults.inc
Implements hook_default_rules_configuration().
commerce_payment_entity_info in modules/payment/commerce_payment.module
Implements of hook_entity_info().
commerce_payment_handler_filter_payment_method::get_value_options in modules/payment/includes/views/handlers/commerce_payment_handler_filter_payment_method.inc
Child classes should be used to override this function and set the 'value options', unless 'options callback' is defined as a valid function or static public method to generate these values.
commerce_payment_method_get_title in modules/payment/commerce_payment.module
Returns the title of any or all payment methods.
commerce_payment_method_load in modules/payment/commerce_payment.module
Returns a payment method array.

... See full list

5 string references to 'commerce_payment_methods'
commerce_payment_entity_load in modules/payment/commerce_payment.module
Implements hook_entity_load().
commerce_payment_methods_reset in modules/payment/commerce_payment.module
Resets the cached list of payment methods.
commerce_payment_pane_checkout_form in modules/payment/includes/commerce_payment.checkout_pane.inc
Payment pane: form callback.
commerce_payment_ui_admin_page in modules/payment/includes/commerce_payment_ui.admin.inc
Builds the payment settings page using the Rules UI overview table filtered to display payment method rules.
commerce_payment_ui_form_commerce_payment_ui_add_payment_rule_form_alter in modules/payment/commerce_payment_ui.module
Implements hook_form_FORM_ID_alter().

File

modules/payment/commerce_payment.module, line 526
Defines the payment system and checkout integration.

Code

function commerce_payment_methods() {
  $payment_methods =& drupal_static(__FUNCTION__);

  // If the payment methods haven't been defined yet, do so now.
  if (!isset($payment_methods)) {
    $payment_methods = array();

    // Build the payment methods array, including module names for the purpose
    // of including files if necessary.
    foreach (module_implements('commerce_payment_method_info') as $module) {
      foreach (module_invoke($module, 'commerce_payment_method_info') as $method_id => $payment_method) {
        $payment_method['method_id'] = $method_id;
        $payment_method['module'] = $module;
        $payment_methods[$method_id] = $payment_method;
      }
    }
    drupal_alter('commerce_payment_method_info', $payment_methods);
    foreach ($payment_methods as $method_id => &$payment_method) {
      $defaults = array(
        'method_id' => $method_id,
        'base' => $method_id,
        'title' => '',
        'description' => '',
        'active' => FALSE,
        'checkout' => TRUE,
        'terminal' => TRUE,
        'offsite' => FALSE,
        'offsite_autoredirect' => FALSE,
        'callbacks' => array(),
        'file' => '',
      );
      $payment_method += $defaults;

      // Default the display title to the title if necessary.  The display title
      // is used in instances where the payment method has an official name used
      // as the title (i.e. PayPal WPS) but a different method of display on
      // selection forms (like some text and a set of images).
      if (empty($payment_method['display_title'])) {
        $payment_method['display_title'] = $payment_method['title'];
      }

      // Default the short title to the title if necessary.  Like the display
      // title, the short title is an alternate way of displaying the title to
      // the user consisting of plain text but with unnecessary information
      // stripped off.  The payment method title might be PayPal WPS as it
      // distinguishes itself from other PayPal payment services, but you would
      // only want to display PayPal to the customer as their means of payment.
      if (empty($payment_methods[$method_id]['short_title'])) {
        $payment_method['short_title'] = $payment_method['title'];
      }

      // Merge in default callbacks.
      foreach (array(
        'settings_form',
        'submit_form',
        'submit_form_validate',
        'submit_form_submit',
        'redirect_form',
        'redirect_form_back',
        'redirect_form_validate',
        'redirect_form_submit',
      ) as $callback) {
        if (!isset($payment_method['callbacks'][$callback])) {
          $payment_method['callbacks'][$callback] = $payment_method['base'] . '_' . $callback;
        }
      }
    }
  }
  return $payment_methods;
}