You are here

function commerce_cardonfile_token_info in Commerce Card on File 7.2

Implements hook_token_info().

Provides commerce-cardonfile-charge-card-response tokens.

File

./commerce_cardonfile.tokens.inc, line 13
Provides token integration.

Code

function commerce_cardonfile_token_info() {
  $properties = commerce_cardonfile_charge_card_response_property_info_callback();

  // Remove unsupported properties.
  unset($properties['card_chosen']);

  // Translate properties to tokens.
  $tokens = array();
  foreach ($properties as $property_name => $property_info) {
    $name = str_replace('_', '-', $property_name);
    $description = $property_info['label'];
    if (!empty($property_info['description'])) {
      $description = $property_info['description'];
    }
    $tokens['commerce-cardonfile-charge-card-response'][$name] = array(
      'name' => $property_info['label'],
      'description' => $description,
      'type' => str_replace('_', '-', $property_info['type']),
    );
  }
  return array(
    'types' => array(
      'commerce-cardonfile-charge-card-response' => array(
        'name' => t('Charge Card on File Response'),
        'description' => t('Tokens related to the Card on File charge response.'),
        'needs-data' => 'commerce-cardonfile-charge-card-response',
      ),
    ),
    'tokens' => $tokens,
  );
}