You are here

function commerce_stripe_commerce_payment_method_info_alter in Commerce Stripe 7

Same name and namespace in other branches
  1. 7.3 commerce_stripe.module \commerce_stripe_commerce_payment_method_info_alter()
  2. 7.2 commerce_stripe.module \commerce_stripe_commerce_payment_method_info_alter()

Implements hook_commerce_payment_method_info_alter().

Displays a warning if Stripe private and public keys are not set and the user has permission to administer payment methods.

File

./commerce_stripe.module, line 708
This module provides Stripe (http://stripe.com/) payment gateway integration to Commerce. Commerce Stripe offers a PCI-compliant way to process payments straight from you Commerce shop.

Code

function commerce_stripe_commerce_payment_method_info_alter(&$payment_methods) {
  if (isset($payment_methods['commerce_stripe'])) {

    // Just return if they don't have permission to see these errors.
    if (!user_access('administer payment methods')) {
      return;
    }
    $found_errors = FALSE;
    $settings = _commerce_stripe_load_settings();

    // If secret_key or public_key is not set.
    if (empty($settings['secret_key']) || empty($settings['public_key'])) {
      $found_errors = TRUE;
      drupal_set_message(t('Stripe secret and public key are required in order to use Stripe payment method. See README.txt for instructions.'), 'warning');
    }

    // If integration_type is not set.
    if (empty($settings['integration_type'])) {
      $found_errors = TRUE;
      drupal_set_message(t('The Stripe payment method "Integration type" is not set. Stripe.js will be used by default.'), 'warning');
    }

    // If they need to configure anything, be nice and give them the link.
    if ($found_errors) {
      $link = l(t('configured here'), 'admin/commerce/config/payment-methods');
      drupal_set_message(t('Settings required for the Stripe payment method can be !link.', array(
        '!link' => $link,
      )), 'warning');
    }
  }
}