add Isracard support, RT#13529
authorivan <ivan>
Tue, 12 Jul 2011 03:25:51 +0000 (03:25 +0000)
committerivan <ivan>
Tue, 12 Jul 2011 03:25:51 +0000 (03:25 +0000)
BINS
Changes
CreditCard.pm
t/test.t

diff --git a/BINS b/BINS
index d3e0cfd..51f099a 100644 (file)
--- a/BINS
+++ b/BINS
@@ -10,11 +10,15 @@ Discover                          6011                             16
 JCB                               3                                16
 JCB                               2131, 1800                       15
 
+--
+
 from Neale Banks <neale@lowendale.com.au>
 According to a booklet I have from Westpac (an Aussie bank), a card number
 starting with 5610 or 56022[1-5] is a BankCard
 BankCards have exactly 16 digits.
 
+--
+
 from "Becker, Max" <Max.Becker@firstgate.com>
 It's mostly used in the UK and is either called "Switch" or "Solo".
 Card Type                         Prefix                           Length
@@ -31,6 +35,8 @@ switch
    8[1-2]
 4936
 
+--
+
 from http://en.wikipedia.org/wiki/Credit_card_number#Prefixes
 As of November 8, 2004, MasterCard and Diner's club formed an alliance.
 Cards issued in Canada and the USA start with 55 and are treated as
@@ -64,10 +70,14 @@ Minimum IIN             Maximum IIN             Product
 Please ensure that your POS terminals, websites and any pertinent
 internal systems can accept these new IINs.
 
+--
+
 from http://en.wikipedia.org/wiki/Laser_(debit_card)#Technical
 Laser cards are prefixed with either "6304", "6706", "6771" or "6709", and
 may be between 16 and 19 characters in length.
 
+--
+
 from https://www.discovernetworkvar.com/pdf_docs/9-2_VAR_ALERT_Sep_2009.pdf
 Be sure to update your POS systems now with the following expanded Issuer
 Identification Number ("IIN") Ranges.  The IIN Range table listed below
@@ -106,3 +116,16 @@ Northern Mariana Islands and Guam, subject to certain exceptions in Acquir
 applicable.
 2 The PAN length for this IIN Range (36000000 to 36999999) is 14 digits.
 
+--
+
+from SBH Israel / Nir Alfandari:
+Local Isracard: 8(-9?) digits
+
+From http://www.wysiwyg.co.il/Anatomy-of-CreditCard-Number-formats.asp#IsraCard-algorithm
+8-9 digits, non-LUHN validation
+
+From Erik Levinse:
+ i think it's like luhn, except instead of 212121... you put
++987654321 under the number you're validating, multiply each, and do mod 11 on
++the sum, instead of mod 10.
+
diff --git a/Changes b/Changes
index 5a53a07..f90aa40 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
 Revision history for Perl extension Business::CreditCard.
 
 0.32  unreleased
+        - Add Israeli Isracard (no checksum yet)
         - Add LICENSE=>perl to Makefile.PL; add license to META.yml,
           closes: cpan #27735
 
index ba63d63..4993f4e 100644 (file)
@@ -5,7 +5,7 @@ use vars qw( @ISA $VERSION $Country );
 
 @ISA = qw( Exporter );
 
-$VERSION = "0.31";
+$VERSION = "0.32_01";
 
 $Country = 'US';
 
@@ -49,6 +49,7 @@ Possible return values are:
   Solo
   China Union Pay
   Laser
+  Isracard
   Unknown
 
 "Not a credit card" is returned on obviously invalid data values.
@@ -130,7 +131,7 @@ types.  Lee also contributed a working test.pl.  Alexandr Ciornii
 
 Copyright (C) 1995,1996,1997 Jon Orwant
 Copyright (C) 2001-2006 Ivan Kohler
-Copyright (C) 2007-2009 Freeside Internet Services, Inc.
+Copyright (C) 2007-2011 Freeside Internet Services, Inc.
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself, either Perl version 5.8.8 or,
@@ -160,7 +161,11 @@ sub cardtype {
     #$number =~ s/\D//g;
     {
       local $^W=0; #no warning at next line
-      return "Not a credit card" unless length($number) >= 13 && 0+$number;
+      return "Not a credit card"
+        unless ( length($number) >= 13
+                 || length($number) == 8 || length($number) == 9 #Isracard
+               )
+            && 0+$number;
     }
 
     return "Switch"
@@ -205,11 +210,17 @@ sub cardtype {
     return "Laser"
       if $number =~ /^6(304|7(06|09|71))[\dx]{12,15}$/o;
 
+    return "Isracard"
+      if $number =~ /^[\dx]{8,9}$/;
+
     return "Unknown";
 }
 
 sub generate_last_digit {
     my ($number) = @_;
+
+    #XXX doesn't work for Isracard, should die
+
     my ($i, $sum, $weight);
 
     $number =~ s/\D//g;
@@ -224,12 +235,16 @@ sub generate_last_digit {
 
 sub validate {
     my ($number) = @_;
+
     my ($i, $sum, $weight);
     
     return 0 if $number =~ /[^\d\s]/;
 
     $number =~ s/\D//g;
 
+    return 1 if $number =~ /^[\dx]{8,9}$/; #XXX Isracard does not use LUHN,
+                                           # validation not yet implemented
+
     return 0 unless length($number) >= 13 && 0+$number;
 
     for ($i = 0; $i < length($number) - 1; $i++) {
index 5cb10b8..37a903d 100644 (file)
--- a/t/test.t
+++ b/t/test.t
@@ -42,6 +42,8 @@ sub test_card_identification {
                 '5610xxxxxxxxxxxx' =>   'BankCard',
                 '6250xxxxxxxxxxxx' =>   'Discover card', #China Union Pay
                 '6280xxxxxxxxxxxx' =>   'Discover card', #China Union Pay
+                '12345678'  => 'Isracard',
+                '123456780' => 'Isracard',
         );
         while( my ($k, $v)=each(%test_table) ){
                 if(cardtype($k) ne $v){