You are here

function commerce_cardonfile_menu in Commerce Card on File 7.2

Same name and namespace in other branches
  1. 7 commerce_cardonfile.module \commerce_cardonfile_menu()

Implements hook_menu().

File

./commerce_cardonfile.module, line 37
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_menu() {
  $items = array();
  $items['admin/commerce/config/cardonfile'] = array(
    'title' => 'Card on file settings',
    'description' => 'Configure your card on file settings.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'commerce_cardonfile_settings_form',
    ),
    'access arguments' => array(
      'configure cardonfile',
    ),
    'file' => 'includes/commerce_cardonfile.admin.inc',
  );
  $items['admin/commerce/config/cardonfile/settings'] = array(
    'title' => 'Settings',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );
  $items['user/%user/cards/add'] = array(
    'title' => 'Add a card',
    'page callback' => 'commerce_cardonfile_add_page',
    'access callback' => 'commerce_cardonfile_add_any_access',
    'access arguments' => array(
      1,
    ),
    'type' => MENU_LOCAL_ACTION,
    'file' => 'includes/commerce_cardonfile.pages.inc',
  );
  $create_implements = commerce_cardonfile_payment_method_implements('create callback');
  foreach ($create_implements as $method_id => $method_function) {
    $payment_method_instances = _commerce_cardonfile_payment_method_instances($method_id);
    foreach ($payment_method_instances as $instance_id => $payment_method) {
      $new_card = commerce_cardonfile_new(array(
        'instance_id' => $instance_id,
        'payment_method' => $payment_method['method_id'],
      ));
      $items['user/%user/cards/add/' . drupal_hash_base64($instance_id)] = array(
        'title' => 'Add a card for payments with !name',
        'title arguments' => array(
          '!name' => $payment_method['display_title'],
        ),
        'page callback' => 'commerce_cardonfile_card_form_page',
        'page arguments' => array(
          'create',
          $new_card,
          1,
        ),
        'access callback' => 'commerce_cardonfile_access',
        'access arguments' => array(
          'create',
          $new_card,
          1,
        ),
        'file' => 'includes/commerce_cardonfile.pages.inc',
      );
    }
  }
  $items['user/%user/cards/%commerce_cardonfile/edit'] = array(
    'title callback' => 'commerce_cardonfile_card_title',
    'title arguments' => array(
      3,
    ),
    'page callback' => 'commerce_cardonfile_card_form_page',
    'page arguments' => array(
      'update',
      3,
      1,
    ),
    'access callback' => 'commerce_cardonfile_access',
    'access arguments' => array(
      'update',
      3,
    ),
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
    'weight' => -10,
    'file' => 'includes/commerce_cardonfile.pages.inc',
  );
  $items['user/%user/cards/%commerce_cardonfile/delete'] = array(
    'title' => 'Delete',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'commerce_cardonfile_delete_form',
      3,
    ),
    'access callback' => 'commerce_cardonfile_access',
    'access arguments' => array(
      'delete',
      3,
    ),
    'context' => MENU_CONTEXT_INLINE,
    'weight' => 5,
    'file' => 'includes/commerce_cardonfile.pages.inc',
  );
  return $items;
}