Hagen-ga,
Thanks for asking the question. I never noticed that card numbers were
coded that way until you asked. The answer for the first couple cards,
American Express - 34 and 37
Master Card - 51,52,53,54,55
Visa - 4 (just one digit)
Are from a BrainJar.com article by Brian Half on the subject of credit
card number Validation Algorithms.
http://www.brainjar.com/js/validation/default2.asp
The Discover, and especially the Diners Club were a little tougher to
turn up, but I found them in a couple Java Scripts for credit card
validation, such as the one at Internet.com.
Discover - 6011 (four digits)
Diners Club - 30,36 and 38
along with two more four-digit prefix cards I'd never heard of:
enRoute card - 2014, 2149
JCB card - 3088,3096,3112,3158,3337,3528
http://javascript.internet.com/forms/val-credit-card.html
Then I thought I'd look for a Perl script, in case you were
interested, and found some slight differences for JCB and Diners Club:
Diners Club - 300,301,302,303,304,305 or 36,38 (however, note the 3
digit codes all begin with 30)
JCB - 2131, 1800 or 3
http://perl.about.com/library/weekly/aa080600g.htm
So, just to sum up (in the order of your question)
Mastercard - 51, 52, 53, 54, 55
Visa - 4
Discover - 6011
AMEX - 34, 37
Diners - 30, 36 and 38
And note that the allowable numbers aren't limited to the first couple
digits. For example, the "30" for Diners Club is really short-hand for
the constraint 3000 to 3059 for the first 4 digits. However, the "30"
is sufficient to identify the card as a Diners Club, which sounds like
all that you're interested in. A pretty clear piece of code PHP
showing the ranges can be found at
http://www.analysisandsolutions.com/code/ccvs-ph.htm
I hope this answers your question fully. |