function commerce_braintree_js_form_validate in Commerce Braintree 7.2
Same name and namespace in other branches
- 7.3 commerce_braintree.module \commerce_braintree_js_form_validate()
Validation callback for the Braintree JS based payment methods.
See also
CALLBACK_commerce_payment_method_submit_form_validate()
2 string references to 'commerce_braintree_js_form_validate'
- commerce_braintree_dropin_commerce_payment_method_info in modules/
commerce_braintree_dropin/ commerce_braintree_dropin.module - Implements hook_commerce_payment_method_info().
- commerce_braintree_hostedfields_commerce_payment_method_info in modules/
commerce_braintree_hostedfields/ commerce_braintree_hostedfields.module - Implements hook_commerce_payment_method_info().
File
- ./
commerce_braintree.module, line 817 - Integrates Braintree Transparent Redirect with Drupal Commerce.
Code
function commerce_braintree_js_form_validate($payment_method, $pane_form, &$pane_values, $order, $charge) {
// Make sure we have a valid nonce (sale token) returned from Braintree.
$nonce = commerce_braintree_js_get_nonce();
// If this is not a card on file transaction, then a nonce is required.
if (empty($nonce) && (empty($pane_values['cardonfile']) || $pane_values['cardonfile'] == 'new')) {
form_set_error('commerce_braintree', t('We were unable to charge your card at this time.'));
return FALSE;
}
}