Eli5: How do they know if it is a valid card number?

344 views

When you are asked to input your card information online, how is it that some websites can automatically know if you input an invalid number and others cannot, before payment is processed?Example: as soon as I typed the last number of my card wrong, it went red and would not allow me to continue before I corrected it.

In: 340

8 Answers

Anonymous 0 Comments

Eli5: the first couple of digits and the last digit are important, and can be compared with the other digits you entered to do a quick check to see if your card number is definitely invalid.

The first digit or two determine what type of card you have (visa, amex, MasterCard etc), which says how many digits you should have in total, and what the CVV should be like.

The last digit is a “check digit”. It’s calculated using a special formula that will add up to the wrong number if you make one of the most common mistakes people make when copying data (ie. Swapped digits, one number wrong, one number skipped etc.). There’s actually a lot of science and testing that went into that algorithm/calculation – which uses a single digit to check all the other digits in your input.

These checks are done by your web browser (not the server), before your data is submitted. Once you submit the data the web server either checks with the bank, or does a few extra checks before storing your data for future sending to the bank (these are called MOTO transactions in the industry, originally meaning Mail Order / Telephone Order transactions).

(This is a ELI5. Other top level replies have more detail if you’re curious)

You are viewing 1 out of 8 answers, click here to view all answers.