Project:
UbercartCategory:
bug reportVersion:
Ubercart 1.0 RCPriority:
normalStatus:
fixed2 issues here. 1, If your using a new card type, it fails every time. 2, your not initating the varable before you use it. Here is a slightly updated version which worked for me
/**
* Validate a CVV number during checkout.
*/
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;
}
if ( ( !empty($digits) AND !in_array(strlen($cvv), $digits) ) || !is_numeric($cvv)) {
return FALSE;
}
return TRUE;
}I check if a limit is added, only then does it check its the right length.
As an aside, it might be nice to re-vamp the CC adding interface, have each card as a db entry with say, name, ccv length, regexp for card validation etc... just a thought.



Re: CCV validation issue
I like your changes here, and I hadn't really thought about the limitation of the select box potentially having different options than I accounted for in the CVV validation. For CC cards, there's a simple checksum that I've included to validate numbers.
I'm gonna go ahead and add in your fix, though I'll note to that another fix might be to just remove the length validation at all and let the CC processors sort that one out.
+1 for revisiting in Uber 2.0.