2 use Test::More tests => 1;
3 use Business::CreditCard;
5 ok( test_card_identification() );
7 sub test_card_identification {
9 # For the curious the table of test number aren't real credit card
10 # in fact they won't validate but they do obey the rule for the
11 # cardtype table to identify the card type.
14 '5212345678901234' => 'MasterCard',
15 '5512345678901234' => 'MasterCard',
16 '2512345678901234' => 'MasterCard',
17 '4123456789012' => 'VISA card',
18 '4512345678901234' => 'VISA card',
19 '341234567890123' => 'American Express card',
20 '371234567890123' => 'American Express card',
21 #'36123456789012' => "Diner's Club/Carte Blanche",
22 #'36123456789012' => 'MasterCard',
23 '36123456789012' => 'Discover card',
24 '201412345678901' => 'enRoute',
25 '214912345678901' => 'enRoute',
26 '6011123456789012' => 'Discover card',
27 '3123456789012345' => 'JCB',
28 '213112345678901' => 'JCB',
29 '180012345678901' => 'JCB',
30 '1800123456789012' => 'Unknown',
31 '312345678901234' => 'Unknown',
32 '4111xxxxxxxxxxxx' => 'VISA card',
33 '6599xxxxxxxxxxxx' => 'Discover card',
34 '6222xxxxxxxxxxxx' => 'Discover card', #China Union Pay
35 '6304980000000000004' => 'Laser',
36 '6499xxxxxxxxxxxx' => 'Discover card',
37 '5610xxxxxxxxxxxx' => 'BankCard',
38 '6250xxxxxxxxxxxx' => 'Discover card', #China Union Pay
39 '6280xxxxxxxxxxxx' => 'Discover card', #China Union Pay
40 '12345678' => 'Isracard',
41 '123456780' => 'Isracard',
43 while( my ($k, $v)=each(%test_table) ){
44 if(cardtype($k) ne $v){
45 warn "Card $k - should be $v but cardtype returns ". cardtype($k). "\n";