You are here

function _uc_credit_valid_cvv in Ubercart 7.3

Validates a CVV number during checkout.

2 calls to _uc_credit_valid_cvv()
uc_payment_method_credit in payment/uc_credit/uc_credit.module
Callback function for the Credit Card payment method.
uc_payment_method_credit_form in payment/uc_credit/uc_credit.module
Displays the credit card details form on the checkout screen.

File

payment/uc_credit/uc_credit.module, line 808
Defines the credit card payment method and hooks in payment gateways.

Code

function _uc_credit_valid_cvv($cvv) {
  $digits = array();
  if (variable_get('uc_credit_visa', TRUE) || variable_get('uc_credit_mastercard', TRUE) || variable_get('uc_credit_discover', TRUE)) {
    $digits[] = 3;
  }
  if (variable_get('uc_credit_amex', TRUE)) {
    $digits[] = 4;
  }

  // Fail validation if it's non-numeric or an incorrect length.
  if (!is_numeric($cvv) || count($digits) > 0 && !in_array(strlen($cvv), $digits)) {
    return FALSE;
  }
  return TRUE;
}