You are here

function _valid_cvv in Ubercart 5

Same name and namespace in other branches
  1. 6.2 payment/uc_credit/uc_credit.module \_valid_cvv()
2 calls to _valid_cvv()
uc_payment_method_credit in payment/uc_credit/uc_credit.module
uc_payment_method_credit_form in payment/uc_credit/uc_credit.module

File

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

Code

function _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;
}