Click here to Skip to main content
15,892,059 members
Articles / Web Development / ASP.NET
Alternative
Tip/Trick

Test Credit Card Account Numbers

Rate me:
Please Sign up or sign in to vote.
4.71/5 (6 votes)
2 Oct 2011CPOL1 min read 20.8K   7   1
Prefix, Length, and Check Digit CriteriaHere is a table outlining the major credit cards that you might want to validate.CARD TYPE Prefix Length Check digit algorithmMASTERCARD 51-55 16 mod 10VISA 4 13, 16 mod 10AMEX 3437 15 mod 10Diners Club/Carte...
  1. Prefix, Length, and Check Digit Criteria
     
    Here is a table outlining the major credit cards that you might want to validate.
     
    CARD TYPE Prefix Length Check digit algorithm
    MASTERCARD 51-55 16 mod 10
    VISA 4 13, 16 mod 10
    AMEX 34
    37 15 mod 10
    Diners Club/
    Carte Blanche 300-305
    36
    38 14 mod 10
    Discover 6011 16 mod 10
    enRoute 2014
    2149 15 any
    JCB 3 16 mod 10
    JCB 2131
    1800 15 mod 10
     
  2. LUHN Formula (Mod 10) for Validation of Primary Account Number
The following steps are required to validate the primary account number:
 
Step 1: Double the value of alternate digits of the primary account number beginning with the second digit from the right (the first right--hand digit is the check digit.)
 
Step 2: Add the individual digits comprising the products obtained in Step 1 to each of the unaffected digits in the original number.
 
Step 3: The total obtained in Step 2 must be a number ending in zero (30, 40, 50, etc.) for the account number to be validated.
 
For example, to validate the primary account number 49927398716:
 
Step 1:
 
4 9 9 2 7 3 9 8 7 1 6
x2 x2 x2 x2 x2
------------------------------
18 4 6 16 2
 

 

Step 2: 4 +(1+8)+ 9 + (4) + 7 + (6) + 9 +(1+6) + 7 + (2) + 6
 
Step 3: Sum = 70 : Card number is validated
 
Note: Card is valid because the 70/10 yields no remainder.
 
Source: http://www.beachnet.com/~hstiles/cardtype.html[^]

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Student
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralReason for my vote of 5 Good for validation Pin
MaulikDusara25-Sep-11 20:49
MaulikDusara25-Sep-11 20:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.