function uc_stripe_settings_form_validate in Ubercart Stripe 7.2
Same name and namespace in other branches
- 6.2 uc_stripe.module \uc_stripe_settings_form_validate()
- 7.3 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_method_settings_form_alter in ./
uc_stripe.module - Implements hook_form_FORMID_alter()
File
- ./
uc_stripe.module, line 347 - 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',
);
if ($form_state['values']['uc_pg_uc_stripe_enabled']) {
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,
)));
}
}
}
// Make sure they haven't tried to validate credit card numbers, as uc_stripe will not provide a real one.
if (!empty($form_state['values']['uc_credit_validate_numbers'])) {
form_set_error('uc_credit_validate_numbers', t('When used with Ubercart Stripe, "Validate credit card number at checkout" must be unchecked.'));
}
}