You are here

function uc_stripe_settings_form_validate in Ubercart Stripe 6.2

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

Validation function and normalize keys (trim spaces)

_state

Parameters

$form:

1 string reference to 'uc_stripe_settings_form_validate'
uc_stripe_form_uc_payment_gateways_form_alter in ./uc_stripe.module
Implements hook_form_FORMID_alter()

File

./uc_stripe.module, line 233
A stripe.js PCI-compliant payment gateway Forked from Bitcookie's work (thanks!) which was posted at http://bitcookie.com/blog/pci-compliant-ubercart-and-stripe-js from discussion in the uc_stripe issue queue, https://www.drupal.org/node/1467886

Code

function uc_stripe_settings_form_validate($form, &$form_state) {
  $elements = array(
    'uc_stripe_api_key_test_secret',
    'uc_stripe_api_key_test_publishable',
    'uc_stripe_api_key_live_secret',
    'uc_stripe_api_key_live_publishable',
  );
  foreach ($elements as $element_name) {
    $form_state['values'][$element_name] = _uc_stripe_sanitize_key($form_state['values'][$element_name]);
    if (!_uc_stripe_validate_key($form_state['values'][$element_name])) {
      form_set_error($element_name, t('@name does not appear to be a valid stripe key', array(
        '@name' => $element_name,
      )));
    }
  }
}