CreditCardValidate

Stable Version 1.1.3 (Compatible with OutSystems 11)
Published on 28 August 2020 by 
0.0
 (0 ratings)

CreditCardValidate

Documentation


How to validate a Credit Card Number?

Most credit card number can be validated using the Luhn algorithm, which is more or a less a glorified Modulo 10 formula!

The Luhn Formula:

  • Drop the last digit from the number. The last digit is what we want to check against
  • Reverse the numbers
  • Multiply the digits in odd positions (1, 3, 5, etc.) by 2 and subtract 9 to all any result higher than 9
  • Add all the numbers together
  • The check digit (the last number of the card) is the amount that you would need to add to get a multiple of 10 (Modulo 10)

Luhn Example:

Step















Total
Original Number:4556737586899855
Drop the last digit:455673758689985

Reverse the digits:589986857376554

Multiple odd digits by 2:1081891661651431461058

Subtract 9 to numbers over 9:189976755356158

Add all numbers:189976755356158
85
Mod 10:85 modulo 10 = 5 (last digit of card)


List of credit card number formats

Credit Card IssuerStarts With ( IIN Range )Length ( Number of digits )
American Express34, 3715
Diners Club - Carte Blanche300, 301, 302, 303, 304, 30514
Diners Club - International3614
Diners Club - USA & Canada5416
Discover6011, 622126 to 622925, 644, 645, 646, 647, 648, 649, 6516-19
InstaPayment637, 638, 63916
JCB3528 to 358916-19
Maestro5018, 5020, 5038, 5893, 6304, 6759, 6761, 6762, 676316-19
MasterCard51, 52, 53, 54, 55, 222100-27209916
Visa413-16-19
Visa Electron4026, 417500, 4508, 4844, 4913, 491716


For more information about cards, see

Credit Cards Validates:
Visa, MasterCard, Elo, American Express, Discover Network, Hipercard, Diners Club, Aura, Maestro, Good Card, JCB, Sorocred