You are here

function _valid_cvv in Ubercart 6.2

Same name and namespace in other branches
  1. 5 payment/uc_credit/uc_credit.module \_valid_cvv()

Validates a CVV number during checkout.

2 calls to _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 1404
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;
}