You are here

function commerce_payment_example_submit_form_validate in Commerce Core 7

Payment method callback: submit form validation.

File

modules/payment/modules/commerce_payment_example.module, line 39
Provides an example payment method for Drupal Commerce for testing and development.

Code

function commerce_payment_example_submit_form_validate($payment_method, $pane_form, $pane_values, $order, $form_parents = array()) {

  // Validate the credit card fields.
  module_load_include('inc', 'commerce_payment', 'includes/commerce_payment.credit_card');
  $settings = array(
    'form_parents' => array_merge($form_parents, array(
      'credit_card',
    )),
  );

  // Even though a form error triggered by the validate handler would be enough
  // to stop the submission of the form, it's not enough to stop it from a
  // Commerce standpoint because of the combined validation / submission going
  // on per-pane in the checkout form. Thus even with a call to form_set_error()
  // this validate handler must still return FALSE.
  if (!commerce_payment_credit_card_validate($pane_values['credit_card'], $settings)) {
    return FALSE;
  }
}