You are here

function uc_stripe_requirements in Ubercart Stripe 7.2

Same name and namespace in other branches
  1. 8.3 uc_stripe.install \uc_stripe_requirements()
  2. 8.2 uc_stripe.install \uc_stripe_requirements()
  3. 6.2 uc_stripe.install \uc_stripe_requirements()
  4. 6 uc_stripe.install \uc_stripe_requirements()
  5. 7.3 uc_stripe.install \uc_stripe_requirements()
  6. 7 uc_stripe.install \uc_stripe_requirements()

Implements hook_requirements().

File

./uc_stripe.install, line 12
Installation file for the uc_stripe module.

Code

function uc_stripe_requirements($phase) {
  $t = get_t();
  $has_curl = function_exists('curl_init');
  $requirements['uc_stripe_curl'] = array(
    'title' => $t('cURL'),
    'value' => $has_curl ? $t('Enabled') : $t('Not found'),
  );
  if (!$has_curl) {
    $requirements['uc_stripe_curl']['severity'] = REQUIREMENT_ERROR;
    $requirements['uc_stripe_curl']['description'] = $t("The Stripe API requires the PHP <a href='!curl_url'>cURL</a> library.", array(
      '!curl_url' => 'http://php.net/manual/en/curl.setup.php',
    ));
  }

  // libraries_info() doesn't work until the module is installed, so allow to be
  // installed without the library. Then warn at that point.
  if ($phase != 'install') {
    $php_api_version = _uc_stripe_load_library();
    $requirements['uc_stripe_api'] = array(
      'title' => $t('Stripe PHP Library'),
      'value' => $t('Version !version', array(
        '!version' => $php_api_version,
      )),
    );
    if (empty($php_api_version)) {
      $requirements['uc_stripe_api']['value'] = $t('Not installed or wrong version');
      $requirements['uc_stripe_api']['severity'] = REQUIREMENT_ERROR;
      $requirements['uc_stripe_api']['description'] = $t('Please install a compatible version of the Stripe PHP Library versions as described in the README.txt');
    }
  }
  $requirements['uc_stripe_keys'] = array(
    'title' => $t('Stripe API Keys'),
    'value' => $t('Configured'),
  );
  if ($phase == 'runtime' && !_uc_stripe_check_api_keys()) {
    $requirements['uc_stripe_keys']['title'] = $t('Stripe API Keys.');
    $requirements['uc_stripe_keys']['value'] = $t('Not configured');
    $requirements['uc_stripe_keys']['severity'] = REQUIREMENT_ERROR;
    $requirements['uc_stripe_keys']['description'] = $t('The Stripe API keys are not fully configured.');
  }

  // Make sure they don't enable the "Check credit"
  if ($phase == 'runtime' && variable_get('uc_credit_validate_numbers', FALSE)) {
    $requirements['uc_stripe_validate_numbers'] = array(
      'title' => t('Stripe Credit Card Validation'),
      'value' => t('Enabled'),
      'severity' => REQUIREMENT_ERROR,
      'description' => t("uc_credit's 'Validate credit card numbers at checkout' option must be disabled when using uc_stripe, as uc_credit never sees the card number."),
    );
  }
  return $requirements;
}