You are here

function commerce_cardonfile_payment_method_implements in Commerce Card on File 7.2

Returns all payment method instances that implement a specific callback

Parameters

$callback: The callback function to return, one of:

  • 'create callback'
  • 'create form callback'
  • 'update callback'
  • 'update form callback'
  • 'delete callback'
  • 'charge callback'

Return value

An array of callback function names keyed by payment method id

5 calls to commerce_cardonfile_payment_method_implements()
commerce_cardonfile_add_any_access in ./commerce_cardonfile.module
Determines if the user can create a card on any payment method.
commerce_cardonfile_add_page in includes/commerce_cardonfile.pages.inc
Menu callback: displays the add card page.
commerce_cardonfile_menu in ./commerce_cardonfile.module
Implements hook_menu().
commerce_cardonfile_payment_method_callback in ./commerce_cardonfile.module
Returns the Card on File callback function for the given payment method.
commerce_cardonfile_rules_payment_instance_charge_options_list in ./commerce_cardonfile.rules.inc
Options list for payment method instances that provide a charge callback

File

./commerce_cardonfile.module, line 1134
Supports card on file functionality for credit card payment methods by associating card data reference IDs from payment gateways with user accounts.

Code

function commerce_cardonfile_payment_method_implements($callback) {
  $cache =& drupal_static(__FUNCTION__);
  if (!isset($cache)) {
    $cache = array();

    // get payment methods and load module implements for hook_commerce_payment_method_info()
    // so that cardonfile callback can be in same hook file, ie mymodule.commerce.inc
    $payment_methods = _commerce_cardonfile_capable_payment_methods();
    $available_callbacks = commerce_cardonfile_payment_method_available_callbacks();
    foreach ($payment_methods as $method_id => $payment_method) {
      foreach ($available_callbacks as $available_callback) {
        if (!empty($payment_method['cardonfile'][$available_callback])) {

          // Include the payment method file if specified.
          if (!empty($payment_method['file'])) {
            $parts = explode('.', $payment_method['file']);
            module_load_include(array_pop($parts), $payment_method['module'], implode('.', $parts));
          }
          $func = $payment_method['cardonfile'][$available_callback];
          if (function_exists($func)) {
            $cache[$available_callback][$method_id] = $func;
          }
        }
      }
    }
  }
  return isset($cache[$callback]) ? $cache[$callback] : array();
}