You are here

function commerce_cardonfile_charge_card_error_level in Commerce Card on File 7.2

Returns the error level for a given card processing response array

1 call to commerce_cardonfile_charge_card_error_level()
commerce_cardonfile_charge_card_get_properties in ./commerce_cardonfile.module
Callback for getting payment transaction properties.

File

./commerce_cardonfile.module, line 1649
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_charge_card_error_level($response) {
  $level = 0;
  $status_codes = commerce_cardonfile_charge_card_status_code_options();
  if (empty($response['code']) || !isset($status_codes[$response['code']])) {
    return $level;
  }
  switch ($response['code']) {
    case COMMERCE_COF_PROCESS_CODE_INSUFFICIENT_DATA:
    case COMMERCE_COF_PROCESS_CODE_CARD_NA:
      $level = 0;
      break;
    case COMMERCE_COF_PROCESS_CODE_METHOD_EMPTY:
    case COMMERCE_COF_PROCESS_CODE_METHOD_NOT_CAPABLE:
      $level = 1;
      break;
    default:

      // Every other possible status code falls into this level of error.
      $level = 2;
      break;
  }
  return $level;
}