public function StripePaymentMethodController::payment_method_configuration_form_elements_validate in Stripe 7
Validate callback for the method configuration form elements.
Parameters
array $element: The parent element.
array $form_state: The form states.
File
- stripe_payment/
includes/ StripePaymentMethodController.inc, line 580 - Stripe Payment controller class and helper code (classes and function).
Class
Code
public function payment_method_configuration_form_elements_validate(array $element, array &$form_state) {
$values = drupal_array_get_nested_value($form_state['values'], $element['#parents']);
if ($values['keys']['mode']) {
foreach (array(
'secret' => 'sk',
'publishable' => 'pk',
) as $type => $prefix) {
if (empty($values['keys'][$type])) {
form_error($element['keys'][$type], t('!name field is required.', array(
'!name' => $element['keys'][$type]['#title'],
)));
}
elseif (strpos($values['keys'][$type], $prefix) !== 0) {
form_error($element['keys'][$type], t('!name should start with %prefix.', array(
'!name' => $element['keys'][$type]['#title'],
'%prefix' => $prefix,
)));
}
}
}
$form_state['payment_method']->controller_data['keys'] = $values['keys'];
}