Re[2]: [PHP-ES] TPV virtuales

From: Date: Wed, 09 Jan 2002 16:35:29 +0000
Subject: Re[2]: [PHP-ES] TPV virtuales
References: 1 2  Groups: php.general.es 
Request: Send a blank email to general-es+get-17548@lists.php.net to get a copy of this message
Buenas, de los dos sistemas que conozco, Banesto y 4B, el más flexible probablemente es el de 4B. Ambos pueden operar en modo de pruebas y me imagino que cualquier otro tambien. En cuanto a la validación de números, utilizo esta función del señor Atkinson. /* ** validateCard($card,$year,$month) ** Input value: card number, year and month ** Ouput values: card type or FALSE ** Card type: AMER, VISA, MAST, DISC ** Check if card is a valid type and number, date are ok ** */ function validateCard($card, $year, $month) { /* ** if any of the three next conditions are true then is not a valid date: ** 1 if year is higher than actual plus 5 OR ** 2 if year is lower than actual OR ** 3 if year is equal to actual and month is lower than actual month */ if ( ($year>date("Y")+5) or ($year<date("Y")) or ( ($year==date("Y")) and ($month<date("n")) ) ){ return FALSE; } //remove non-numbers $card = ereg_replace('[^0-9]','', $card); /* ** determine card type */ /* not used now if(ereg('^3[4|7]', $card) AND (strlen($card) == 15)) { //American Express //Starts with 34 or 37 //15 numbers long $type = 'AMER'; } elseif(ereg('^6011', $card) AND (strlen($card) == 16)) { //Discover //Starts with 6011 //16 numbers long $type = "DISC"; } */ if(ereg('^4', $card ) AND ((strlen($card) == 13) OR (strlen($card) == 16))) { //Visa //Starts with 4 //13 or 16 numbers long $type = 'VISA'; } elseif(ereg('^5[1-5]', $card) AND (strlen($card) == 16)) { //MasterCard //Starts with 51,52,53,54,55 //16 numbers long $type = 'MAST'; } elseif(strlen($card) == 17) { //4B //I Don´t know how starts //17 numbers long $type = "4B"; } else { return(FALSE); } /* ** compute MOD 10 check ** ** 1. Start at last digit and work backwards ** 2. Odd digits to total ** 3. Multiply even digits by 2 and add digits to total ** 4. If sum is divisible by 10, everything's OK */ $check = 0; $mode = "add"; for($i=strlen($card)-1; $i >= 0; $i--) { //alternate between doubling if($mode == "double") { //double digit $sum = strval($card[$i] * 2); //add digits to total $check += intval($sum[0]); if(intval($sum) > 10) { $check += intval($sum[1]); } $mode = "add"; } else { //add digit to total $check += intval($card[$i]); $mode = "double"; } } /* ** Test the check */ if($check % 10) { //not divisible by 10, so it's a bad card return(FALSE); } else { //everything checks out return($type); } } > > Saludos José Valle desarrollo@comerciacom.com B2B Comercia S.A.

« previous php.general.es (#17548) next »