Skip to content

Commit

Permalink
Support new MasterCard BIN ranges
Browse files Browse the repository at this point in the history
Support new MasterCard BIN ranges.
Validate that CVC only contains numbers.
Allow integer values for the expiration date.
  • Loading branch information
inacho committed Jul 3, 2015
1 parent 69d37b2 commit e71ea73
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CreditCard
'cvcLength' => array(3),
'luhn' => true,
),
# Credit cards
// Credit cards
'visa' => array(
'type' => 'visa',
'pattern' => '/^4/',
Expand All @@ -53,7 +53,7 @@ class CreditCard
),
'mastercard' => array(
'type' => 'mastercard',
'pattern' => '/^5[0-5]/',
'pattern' => '/^(5[0-5]|2[2-7])/',
'length' => array(16),
'cvcLength' => array(3),
'luhn' => true,
Expand Down Expand Up @@ -124,11 +124,13 @@ public static function validCreditCard($number, $type = null)

public static function validCvc($cvc, $type)
{
return (array_key_exists($type, self::$cards) && self::validCvcLength($cvc, $type));
return (ctype_digit($cvc) && array_key_exists($type, self::$cards) && self::validCvcLength($cvc, $type));
}

public static function validDate($year, $month)
{
$month = str_pad($month, 2, '0', STR_PAD_LEFT);

if (! preg_match('/^20\d\d$/', $year)) {
return false;
}
Expand Down

0 comments on commit e71ea73

Please sign in to comment.