woz Posted March 4, 2006 Posted March 4, 2006 Hi, I've been having alot of trouble with the CC module. We are going to be running the card details through a machine located on site so we just need to be able to use these at a later date. Currently, everytime we want to take a payment via credit card, we get a an error message saying; 'The credit card number entered is invalid.<br>Please check the number and try again'. Is the credit card validation file there just used to determine the card type? If so, does anyone know of a mod that simply adds a drop down menu so the customer can select a card type? This would be very useful if so. If the customers card details aren't accepted at the machine we can always contact them about this. Many thanks in advance Warren
Guest Posted March 5, 2006 Posted March 5, 2006 find out if this only happens with visa or with every other card type. If its only visa you could try changing the first few lines on the catalog\includes\classes\cc_validation.php from this: if (ereg('^4[0-9]{12}([0-9]{3})?$', $this->cc_number)) { $this->cc_type = 'Visa'; to this if (ereg('^4[0-9]{12}([0-9]{1}|[0-9]{3})?$', $this->cc_number)) { $this->cc_type = 'Visa'; and basically that's the file you need to edit to support more card types.
woz Posted March 6, 2006 Author Posted March 6, 2006 find out if this only happens with visa or with every other card type. If its only visa you could try changing the first few lines on the catalog\includes\classes\cc_validation.php from this: if (ereg('^4[0-9]{12}([0-9]{3})?$', $this->cc_number)) { $this->cc_type = 'Visa'; to this if (ereg('^4[0-9]{12}([0-9]{1}|[0-9]{3})?$', $this->cc_number)) { $this->cc_type = 'Visa'; and basically that's the file you need to edit to support more card types. Many thanks for your reply. I have tried other cards, and altered the code to the above but still get the error message; 'The credit card number entered is invalid.<br>Please check the number and try again.' The validation for the start of the number works at it says: 'The first four digits of the number entered are: 3453<br>If that number is correct, we do not accept that type of credit card.<br>If it is wrong, please try again.' Is therefore an error somewhere else? Maybe the length of the number?
Guest Posted March 6, 2006 Posted March 6, 2006 I see, this is a different card. What cart type is it? and how many digits? Don't post the cc number here of course. (Is it solo?)
woz Posted March 6, 2006 Author Posted March 6, 2006 It is happening on any card input. Thats what is confusing us! We just need the numbers to go through as the terminal at the office will be processing the card numbers. Please help!
Guest Posted March 6, 2006 Posted March 6, 2006 card numbers go through with the osc files, what happens if you try 4111111111111111 which is the test cc number? Do still you get the error? Also post your catalog\includes\classes\cc_validation.php file
woz Posted March 6, 2006 Author Posted March 6, 2006 Thanks for the reply. Yes the test number does go through. Thanks for the help so far, heres the cc_validation file. Hope you can help... PS. Please excuse if im being slow on this whole matter! <?php /* cc_validation.php,v 1.4 2005/08/01 osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ class cc_validation { //**si** // var $cc_type, $cc_number, $cc_expiry_month, $cc_expiry_year; var $cc_type, $cc_number, $cc_expiry_month, $cc_expiry_year, $cc_start_month, $cc_start_year, $cc_cvv, $cc_issue; //**si** 09-03-03 /// function validate($number, $expiry_m, $expiry_y, $start_m='', $start_y='') { function validate($number, $expiry_m, $expiry_y, $start_m='', $start_y='',$cc_cvv='', $cc_issue='') { //**si** end $this->cc_number = ereg_replace('[^0-9]', '', $number); //**si** // $NumberLeft4 = substr($this->cc_number, 0, 4); $NumberLeft6 = substr($this->cc_number, 0, 6); /***** DELTA *****/ if ( ((($NumberLeft6 >= 413733) && ($NumberLeft6 <= 413737)) || (($NumberLeft6 >= 446200) && ($NumberLeft6 <= 446299)) || (($NumberLeft6 >= 453978) && ($NumberLeft6 <= 453979)) || ($NumberLeft6 == 454313) || (($NumberLeft6 >= 454432) && ($NumberLeft6 <= 454435)) || ($NumberLeft6 == 454742) || (($NumberLeft6 >= 456725) && ($NumberLeft6 <= 456745)) || (($NumberLeft6 >= 465830) && ($NumberLeft6 <= 465879)) || (($NumberLeft6 >= 465901) && ($NumberLeft6 <= 465950)) || (($NumberLeft6 >= 484409) && ($NumberLeft6 <= 484410)) || (($NumberLeft6 >= 490960) && ($NumberLeft6 <= 490979)) /* || (($NumberLeft6 >= 492181) && ($NumberLeft6 <= 492182)) */ || ($NumberLeft6 == 498824) ) && (ereg('[0-9]{16}', $this->cc_number)) ) { $this->cc_type = 'Delta'; if ( strtolower(MODULE_PAYMENT_CC_ACCEPT_DELTA) != 'true' ) return -5; //-- } /***** ELECTRON *****/ elseif (( ($NumberLeft6 == 450875) || (($NumberLeft6 >= 484406) && ($NumberLeft6 <= 484408)) || (($NumberLeft6 >= 484411) && ($NumberLeft6 <= 484455)) || (($NumberLeft6 >= 491730) && ($NumberLeft6 <= 491759)) || ($NumberLeft6 == 491880) ) && (ereg('[0-9]{16}', $this->cc_number)) ) { $this->cc_type = "UK Electron"; if ( strtolower(MODULE_PAYMENT_CC_ACCEPT_ELECTRON) != 'true' ) return -5; //-- } /***** MASTERCARD *****/ elseif ( strtolower(MODULE_PAYMENT_CC_ACCEPT_ORIG_MASTERCARD) != 'true' &&($NumberLeft6 >= 510000) && ($NumberLeft6 <= 559999) && (ereg('[0-9]{16}', $this->cc_number)) ) { $this->cc_type = "MasterCard"; if ( strtolower(MODULE_PAYMENT_CC_ACCEPT_MASTERCARD) != 'true' ) return -5; //-- } /***** SWITCH *****/ elseif (( (($NumberLeft6 >= 490302) && ($NumberLeft6 <= 490309)) || (($NumberLeft6 >= 490335) && ($NumberLeft6 <= 490339)) || (($NumberLeft6 >= 491101) && ($NumberLeft6 <= 491102)) || (($NumberLeft6 >= 491174) && ($NumberLeft6 <= 491182)) || (($NumberLeft6 >= 493600) && ($NumberLeft6 <= 493699)) || ($NumberLeft6 == 564182) || (($NumberLeft6 >= 633300) && ($NumberLeft6 <= 633349)) || (($NumberLeft6 >= 675900) && ($NumberLeft6 <= 675999)) ) && (ereg('[0-9]{16}|[0-9]{18}|[0-9]{19}', $this->cc_number)) ) { $this->cc_type = "Switch"; if ( strtolower(MODULE_PAYMENT_CC_ACCEPT_SWITCH) != 'true' ) return -5; //-- } /***** SOLO *****/ elseif (( (($NumberLeft6 >= 633450) && ($NumberLeft6 <= 633460)) || (($NumberLeft6 >= 633462) && ($NumberLeft6 <= 633472)) || (($NumberLeft6 >= 633474) && ($NumberLeft6 <= 633475)) || ($NumberLeft6 == 633477) || (($NumberLeft6 >= 633479) && ($NumberLeft6 <= 633480)) || (($NumberLeft6 >= 633482) && ($NumberLeft6 <= 633489)) || ($NumberLeft6 == 633498) || (($NumberLeft6 >= 676700) && ($NumberLeft6 <= 676799)) ) && (ereg('[0-9]{16}|[0-9]{18}|[0-9]{19}', $this->cc_number)) ) { $this->cc_type = "Solo"; if ( strtolower(MODULE_PAYMENT_CC_ACCEPT_SOLO) != 'true' ) return -5; //-- } /***** JCB *****/ elseif ( ( strtolower(MODULE_PAYMENT_CC_ACCEPT_ORIG_JCB) != 'true' ) && ( (($NumberLeft6 >= 352800) && ($NumberLeft6 <= 358999)) || ($NumberLeft6 == 411111) ) && (ereg('[0-9]{16}', $this->cc_number)) ) { $this->cc_type = "JCB"; if ( strtolower(MODULE_PAYMENT_CC_ACCEPT_JCB) != 'true' ) return -5; //-- } /***** MAESTRO *****/ elseif (( (($NumberLeft6 >= 493698) && ($NumberLeft6 <= 493699)) || ($NumberLeft6 == 490303) || (($NumberLeft6 >= 633302) && ($NumberLeft6 <= 633349)) || (($NumberLeft6 >= 675900) && ($NumberLeft6 <= 675999)) || (($NumberLeft6 >= 500000) && ($NumberLeft6 <= 509999)) || (($NumberLeft6 >= 560000) && ($NumberLeft6 <= 589999)) || (($NumberLeft6 >= 600000) && ($NumberLeft6 <= 699999)) ) && (ereg('[0-9]{16}', $this->cc_number)) ) { $this->cc_type = "Maestro"; if ( strtolower(MODULE_PAYMENT_CC_ACCEPT_MAESTRO) != 'true' ) return -5; //-- } /***** VISA *****/ elseif ( strtolower(MODULE_PAYMENT_CC_ACCEPT_ORIG_VISA) != 'true' && ( (($NumberLeft6 >= 400000) && ($NumberLeft6 <= 499999)) // ensure we exclude AMT only cards && !( (($NumberLeft6 >= 490300) && ($NumberLeft6 <= 490301)) || (($NumberLeft6 >= 490310) && ($NumberLeft6 <= 490334)) || (($NumberLeft6 >= 490340) && ($NumberLeft6 <= 490399)) || (($NumberLeft6 >= 490400) && ($NumberLeft6 <= 490409)) || ($NumberLeft6 == 490419) || ($NumberLeft6 == 490451) || ($NumberLeft6 == 490459) || ($NumberLeft6 == 490467) || (($NumberLeft6 >= 490475) && ($NumberLeft6 <= 490478)) || (($NumberLeft6 >= 490500) && ($NumberLeft6 <= 490599)) || (($NumberLeft6 >= 491103) && ($NumberLeft6 <= 491173)) || (($NumberLeft6 >= 491183) && ($NumberLeft6 <= 491199)) || (($NumberLeft6 >= 492800) && ($NumberLeft6 <= 492899)) || (($NumberLeft6 >= 498700) && ($NumberLeft6 <= 498799)) ) ) && (ereg('[0-9]{16}|[0-9]{13}', $this->cc_number)) ) { $this->cc_type = 'Visa'; if ( strtolower(MODULE_PAYMENT_CC_ACCEPT_VISA) != 'true' ) return -5; // // back to std system checks // if (ereg('^4[0-9]{12}([0-9]{3})?$', $this->cc_number)) { } elseif (ereg('^4[0-9]{12}([0-9]{3})?$', $this->cc_number)) { //**si**end $this->cc_type = 'Visa'; //**si** if ( strtolower(MODULE_PAYMENT_CC_ACCEPT_ORIG_VISA) != 'true' ) return -5; //**si** end } elseif (ereg('^5[1-5][0-9]{14}$', $this->cc_number)) { $this->cc_type = 'Master Card'; //**si** if ( strtolower(MODULE_PAYMENT_CC_ACCEPT_ORIG_MASTERCARD) != 'true' ) return -5; //**si** end } elseif (ereg('^3[47][0-9]{13}$', $this->cc_number)) { $this->cc_type = 'American Express'; //**si** if ( strtolower(MODULE_PAYMENT_CC_ACCEPT_ORIG_AMERICANEXPRESS) != 'true' ) return -5; //**si** end } elseif (ereg('^3(0[0-5]|[68][0-9])[0-9]{11}$', $this->cc_number)) { $this->cc_type = 'Diners Club'; //**si** if ( strtolower(MODULE_PAYMENT_CC_ACCEPT_ORIG_DINERSCLUB) != 'true' ) return -5; //**si** end } elseif (ereg('^6011[0-9]{12}$', $this->cc_number)) { $this->cc_type = 'Discover'; //**si** if ( strtolower(MODULE_PAYMENT_CC_ACCEPT_ORIG_DISCOVERNOVUS) != 'true' ) return -5; //**si** end } elseif (ereg('^(3[0-9]{4}|2131|1800)[0-9]{11}$', $this->cc_number)) { $this->cc_type = 'JCB'; //**si** if ( strtolower(MODULE_PAYMENT_CC_ACCEPT_ORIG_JCB) != 'true' ) return -5; //**si** end } else { return -1; } //**si** 09-03-03 if ( USE_CC_ISSUE == 'true' ) { if ( ( strtolower($this->cc_type) == "switch" || strtolower($this->cc_type) == "solo" ) && empty($cc_issue) ) { return -11; ///$cc_val = ; } } if ( USE_CC_CVV == 'true' ) { if ( empty($cc_cvv) || strlen(strval($cc_cvv)) != 3 ) { return -12; //$cc_val = ; } } //**si**end if (is_numeric($expiry_m) && ($expiry_m > 0) && ($expiry_m < 13)) { $this->cc_expiry_month = $expiry_m; } else { return -2; } $current_year = date('Y'); $expiry_y = substr($current_year, 0, 2) . $expiry_y; if (is_numeric($expiry_y) && ($expiry_y >= $current_year) && ($expiry_y <= ($current_year + 10))) { $this->cc_expiry_year = $expiry_y; } else { return -3; } if ($expiry_y == $current_year) { if ($expiry_m < date('n')) { return -4; } } //**si** ////die('4 "'.is_numeric($start_m).'" $start_m "'.$start_m.'" $start_y "'.$start_y.'"'); if ( !(is_numeric($start_m) && ($start_m > 0) && ($start_m < 13)) ) { return -6; } $current_year = date('Y'); if ($start_y > 80) { $start_y = '19' . $start_y; } else { $start_y = '20' . $start_y; } if ( !is_numeric($start_y) || ($start_y > $current_year)) { return -6; } if ( !($start_y >= ($current_year - 10)) ) { return -6; } //**08/03/03 ///if ($start_m > date('n') || ( $start_m >= $expire_m && $start_y == $expiry_y) ) { if ( ($start_m >= $expiry_m && $start_y == $expiry_y) || ($start_m > date('n') && $start_y == date('Y'))) { return -6; } $this->cc_start_month = $start_m; $this->cc_start_year = $start_y; //**si** end return $this->is_valid(); } function is_valid() { $cardNumber = strrev($this->cc_number); $numSum = 0; for ($i=0; $i<strlen($cardNumber); $i++) { $currentNum = substr($cardNumber, $i, 1); // Double every second digit if ($i % 2 == 1) { $currentNum *= 2; } // Add digits of 2-digit numbers together if ($currentNum > 9) { $firstNum = $currentNum % 10; $secondNum = ($currentNum - $firstNum) / 10; $currentNum = $firstNum + $secondNum; } $numSum += $currentNum; } // If the total has no remainder it's OK return ($numSum % 10 == 0); } } ?>
woz Posted March 6, 2006 Author Posted March 6, 2006 Hi, I also found the error message occurs from this section of code..:case false: $error = TEXT_CCVAL_ERROR_INVALID_NUMBER; break; what does 'case false' mean? Woz
Guest Posted March 6, 2006 Posted March 6, 2006 yea this is some custom code. It filters the various numbers on a range basis. I guess it has to be expanded to accomodate the cc numbers that fail. Is that code from a contribution?
woz Posted March 6, 2006 Author Posted March 6, 2006 Yes it is from a contribution, but no matter what numbers we try it doesn't go through unless its 411111. What now? :blink:
Guest Posted March 6, 2006 Posted March 6, 2006 what's the link of the contribution? Also if there is a support thread for it they may already have a fix.
woz Posted March 6, 2006 Author Posted March 6, 2006 I obtained it from here. http://www.oscommerce.com/community/contri...ory,1/search,uk I have copied all the up to date files across too. Do you know what the 'case false' section of code means? Or is that just what happens when the values for any of the cards aren't met? Many thanks for your persistance btw :)
Guest Posted March 6, 2006 Posted March 6, 2006 well I cannot locate a support thread for it. But you may want to try the default cc_validation file of the osc and then enhance it for the different cc types. You could also add the extra code for the visa verification. And also check the earlier versions on that contribution if the cc_validation.php file works. Sometimes they upload a version and it's not functional. I could tell you how to remove the entire validation but that's no good because then every number can go to the gateway and you do not want that.
woz Posted March 6, 2006 Author Posted March 6, 2006 Sorry forgot to mention we had this problem with the orginal cc_validation file too which is part of the reason why I got this contribution file. The card numbers will be run through a machine in the office anyway so an incorrect number wouldn't be too much of a problem, however we shall need a method of input from the customer to enter their card type. Do you know of a way of doing this? Thanks
Guest Posted March 6, 2006 Posted March 6, 2006 well you could try removing the digits check and leave the luhn formula intact. <?php /* $Id: cc_validation.php,v 1.3 2003/02/12 20:43:41 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ class cc_validation { var $cc_type, $cc_number, $cc_expiry_month, $cc_expiry_year, $cc_start_month, $cc_start_year, $cc_cvv, $cc_issue; function validate($number, $expiry_m, $expiry_y) { $this->cc_number = ereg_replace('[^0-9]', '', $number); if (is_numeric($expiry_m) && ($expiry_m > 0) && ($expiry_m < 13)) { $this->cc_expiry_month = $expiry_m; } else { return -2; } $current_year = date('Y'); $expiry_y = substr($current_year, 0, 2) . $expiry_y; if (is_numeric($expiry_y) && ($expiry_y >= $current_year) && ($expiry_y <= ($current_year + 10))) { $this->cc_expiry_year = $expiry_y; } else { return -3; } if ($expiry_y == $current_year) { if ($expiry_m < date('n')) { return -4; } } return $this->is_valid(); } function is_valid() { $cardNumber = strrev($this->cc_number); $numSum = 0; for ($i=0; $i<strlen($cardNumber); $i++) { $currentNum = substr($cardNumber, $i, 1); // Double every second digit if ($i % 2 == 1) { $currentNum *= 2; } // Add digits of 2-digit numbers together if ($currentNum > 9) { $firstNum = $currentNum % 10; $secondNum = ($currentNum - $firstNum) / 10; $currentNum = $firstNum + $secondNum; } $numSum += $currentNum; } // If the total has no remainder it's OK return ($numSum % 10 == 0); } } ?> and see if it works.
melinhead Posted April 21, 2006 Posted April 21, 2006 I am having a very similar problem. Everything has been working fine for many months, and then I recently had a customer with a card starting in "5492" (Mastercard) that wouldn't go through. All other cards work fine, except Master Card. I had a guy we use on an hourly basis check it out, and he changed (in cc_validation.php): } elseif (ereg('^5[1-5][0-9]{14}$', $this->cc_number)) { $this->cc_type = 'Mastercard'; TO: } elseif (ereg('^5[1-5][0-9]{124}$', $this->cc_number)) { $this->cc_type = 'Mastercard'; Today I have a different customer telling me that both of her MCs beginning in "5538" and "5588" won't process. She gets the same error "If that card number is correct we do not accept that type of card." I'm not sure how to edit this file, and this is the first thread I've seen that's even close to the problem. This started about 2 months ago. If anyone can tell me how to edit the lines above so these card #s work, that would be great. Maybe it will help others sort out the problems they're having? Mel
Recommended Posts
Archived
This topic is now archived and is closed to further replies.