Source for file CreditCard.class.php
Documentation is available at CreditCard.class.php
* Gumbo Library Framework
* This library is being released under the terms of the New BSD License. A
* copy of the license is packaged with the software (LICENSE.txt). If no
* copy is found, a copy of the license template can be found at:
* http://www.opensource.org/licenses/bsd-license.php
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* Credit Card Validation Class
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* @desc Credit Card Validation Class
* @param bool $throw throw Exceptions
* @param int $level Error Level thrown
public function __construct ($throw=
false, $level=
null) {
* Returns if the value is a Credit Card Number (Luhn Formula)
* @throws Gumbo_Exception
for ($x=
0;$x <
strlen ($val);$x++
) {
if ($x/
2 !=
floor ($x/
2)) {
// if result two digits, add them
$passed =
($total %
10 ==
0);
* Returns if the Credit Card is a VISA
* @throws Gumbo_Exception
$this->isMatch ($val, "/^([4]{1})([0-9]{12,15})$/");
* Returns if the Credit Card is a MasterCARD
* @throws Gumbo_Exception
$this->isMatch ($val, "/^([51|52|53|54|55]{2})([0-9]{14})$/");
* Returns if the Credit Card is a Discover
* @throws Gumbo_Exception
$this->isMatch ($val, "/^([6011]{4})([0-9]{12})$/");
* Returns if the Credit Card is a American Express
* @throws Gumbo_Exception
$this->isMatch ($val, "/^([34|37]{2})([0-9]{13})$/");
* Returns if the Credit Card is a Diner's Club
* @throws Gumbo_Exception
$this->isMatch ($val, "/^([30|36|38]{2})([0-9]{12})$/");