Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 6ef407f

Browse files
committed
Merge pull request #110 from epg-dennis/feature/mastercard-2series-bin
CreditCard: Added new Mastercard 2-series BINs
2 parents 46fcef5 + ae04e16 commit 6ef407f

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/CreditCard.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ class CreditCard extends AbstractValidator
112112
self::LASER => ['6304', '6706', '6771', '6709'],
113113
self::MAESTRO => ['5018', '5020', '5038', '6304', '6759', '6761', '6762', '6763',
114114
'6764', '6765', '6766', '6772'],
115-
self::MASTERCARD => ['51', '52', '53', '54', '55'],
115+
self::MASTERCARD => ['2221', '2222', '2223', '2224', '2225', '2226', '2227', '2228', '2229',
116+
'223', '224', '225', '226', '227', '228', '229',
117+
'23', '24', '25', '26', '271', '2720',
118+
'51', '52', '53', '54', '55'],
116119
self::SOLO => ['6334', '6767'],
117120
self::UNIONPAY => ['622126', '622127', '622128', '622129', '62213', '62214',
118121
'62215', '62216', '62217', '62218', '62219', '6222', '6223',

test/CreditCardTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,44 @@ public function testJcbCard($input, $expected)
213213
$this->assertEquals($expected, $validator->isValid($input));
214214
}
215215

216+
/**
217+
* Data provider
218+
*
219+
* @return string[][]|bool[][]
220+
*/
221+
public function mastercardValues()
222+
{
223+
return [
224+
['4111111111111111', false],
225+
['5011642326344731', false],
226+
['5130982099822729', true],
227+
['2220993834549400', false],
228+
['2221006548643366', true],
229+
['2222007329134574', true],
230+
['2393923057923090', true],
231+
['2484350479254492', true],
232+
['2518224476613101', true],
233+
['2659969950495289', true],
234+
['2720992392889757', true],
235+
['2721008996056187', false],
236+
];
237+
}
238+
239+
/**
240+
* Test mastercard number validity
241+
*
242+
* @dataProvider mastercardValues
243+
*
244+
* @param string $input
245+
* @param bool $expected
246+
*/
247+
public function testMastercardCard($input, $expected)
248+
{
249+
$validator = new CreditCard(['type' => CreditCard::MASTERCARD]);
250+
251+
$this->assertEquals($expected, $validator->isValid($input));
252+
}
253+
216254
/**
217255
* Test an invalid service class
218256
*

0 commit comments

Comments
 (0)