- How do websites know my credit card is valid?
- Do they have these numbers stored or do they pole credit card providers for the information?
A good resource, even though it is Wikipedia, is: http://en.wikipedia.org/wiki/Bank_card_number
The first 6 digits help you identify the vendor of the credit card number. Depending on the vendor, it may only be up to 4.
- 0 – ISO/TC 68 and other future industry assignments
- 1 – Airlines
- 2 – Airlines and other future industry assignments
- 3 – Travel and entertainment and banking/finance
- 4 – Banking and finance
- 5 – Banking and finance
- 6 – Merchandising and banking/finance
- 7 – Petroleum and other future industry assignments
- 8 – Healthcare, telecommunications and other future industry assignments
- 9 – National assignment
In the old days, if you typed in your credit card number and purchased something online or provided your card over the phone, the manufacture would take up to a week to tell you the credit card number is wrong.
Now-a-days they can use an algorithm to validate the credit card number and tell you right away, before you even submit your card, that it is invalid. The algorithm is called the Luhn algorithm. This is the basic concept of how it works:
- From the rightmost digit, which is the check digit, moving left, double the value of every second digit; if the product of this doubling operation is greater than 9, then sum the digits of the products.
- Take the sum of all the digits.
- If the total modulo 10 is equal to 0 (if the total ends in a zero) then the number is valid according to the Luhn formula; else it is not valid.
Since we like to focus on C#, I will post a C# implementation of the Luhn algorithm at a later time.
No comments:
Post a Comment