Luhn Algorithm and Card Validation¶
Luhn Algorithm¶
The Luhn algorithm is used to validate the format of credit card numbers. It checks if the input number matches known card formats and rejects it if invalid.
- Algorithm Steps:
- Start from the rightmost digit (check digit) and move left, doubling every second digit.
- If doubling results in a value greater than 9, add the digits (e.g., 16 → 1 + 6 = 7).
- Take the sum of all the digits.
- If the total modulo 10 is 0, the number is valid.
For more details, see Luhn Algorithm on Wikipedia.
Card Number Length¶
The card number field is flexible to accept all types of credit cards. The validation process runs after the card number is input, ensuring proper format. Longer card numbers that do not match the required format are not accepted.
Allowing flexibility in the input field helps improve the quality of card data, which is why the field length is not restricted.
Prepaid Cards¶
- Invalid Prepaid Bins: Pulled from the BIN database and listed under the Invalid Credit Cards list.
- Custom Forms Menu: Super Admins can access the list under the Custom Forms menu. Regex is used to filter ranges of bin numbers and disallow matching prepaid cards.
The Luhn algorithm is an industry-standard method used for validating credit card formats. Additional checks are in place for prepaid cards to ensure only valid cards are accepted during transactions.