Jump to content

Modulus 10 aka LUHN aka ISO7812 Credit Card Validation


This topic is 8349 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I needed a way to do good CC # input validation, without actually posting to a CC processor in real time, or even before I post to a CC gateway some junk CC#.

I found the MODULUS-10 "double-add-double" check digit method, AKA LUHN Formula, detailed in ISO-7812 Part 1, does several good things for validating the CC number. First, it insures no spaces, alphas, dashes, etc is present in the card number, although this is a trivial thing to verify in Filemaker using other techniques, and should be done anyway before this validation. It does not help in verifying input length but again this is trivial.

So what does it do that is neat?

It verfies, using a checksum algorithm called LUHN or MODULUS-10 "double-add-double", that the card number entered is a valid sequence. It insures that transposed numbers are caught on input, which can be very helpful for the user and merchant! It also helps to pretty much insure only a real card# is used.

Combine this with prefix checking against card type, and maybe a few other small validations, and you can keep pests out too!

This is important for me as I run a realtime inventory based store. Junk orders are just a hassle.

So how to execute this in Filemaker? I couldn't find the answer using the searches on the good forums like this one, so I had to whip it out, and thought I'd share for the next searcher...

First, a better background than what I have given, can be found here:

Modulus-10 CC Validation

Next, the way I did this in Filemaker is here:

For a 16-digit card:

'IF'

Mod(Right(cardnumber,1) + If( Left( Right(cardnumber,2) ,1)*2>9,Mod(Left(Right(cardnumber,2),1)*2 ,10)+1, Left(Right(cardnumber,2),1)*2 )+ Left(Right(cardnumber,3),1) + If( Left(Right(cardnumber,4),1)*2 > 9, Mod(Left(Right(cardnumber,4),1)*2 , 10)+1 , Left(Right(cardnumber,4),1)*2 ) + Left(Right(cardnumber,5),1) + If( Left(Right(cardnumber,6),1)*2 >9,Mod(Left(Right(cardnumber,6),1)*2,10)+1 , Left(Right(cardnumber,6),1)*2 ) + Left(Right(cardnumber,7),1) + If( Left(Right(cardnumber,8),1)*2 >9,Mod(Left(Right(cardnumber,8),1)*2,10)+1 , Left(Right(cardnumber,8),1)*2 ) +Left(Right(cardnumber,9),1) + If( Left(Right(cardnumber,10),1)*2 >9,Mod(Left(Right(cardnumber,10),1)*2,10)+1 , Left(Right(cardnumber,10),1)*2 ) + Left(Right(cardnumber,11),1) + If( Left(Right(cardnumber,12),1)*2 >9,Mod(Left(Right(cardnumber,12),1)*2,10)+1 , Left(Right(cardnumber,12),1)*2 ) + Left(Right(cardnumber,13),1) + If( Left(Right(cardnumber,14),1)*2 >9,Mod(Left(Right(cardnumber,14),1)*2,10)+1 , Left(Right(cardnumber,14),1)*2 ) + Left(Right(cardnumber,15),1) + If( Left(cardnumber,1)*2 >9,Mod(Left(cardnumber,1)*2,10)+1 , Left(cardnumber,1)*2 ) , 10 ) > 0

'SETFIELD "VALID" TO "NO" AND HALT PROCESSING.' or whatever works for you... Your actual application of the formula may vary, but there it is!

To do 13 or 15 digit numbers, just remove the 13, 14, 15 (for 13 digit) or just 15 (for 15 digit) positions.

The Filemaker MOD function saved a lot of work in this formula I would have otherwise had to otherwise account for... Whew, lucky it was there!

Sorry if this has been posted before, or been done better. If anyone has any suggestions pls email. I was in a hurry and figure there's a few ways to groom the above expression.... but for now it works laugh.gif" border="0

Happy Processing!

Steve W.

AirsoftSupply.com

Link to comment
Share on other sites

Here's the English version of what Mod-10 does:

These are the steps in the mod10 test:

Step 1: Multiply the digits in the even positions by 2, starting with the second digit from the RIGHT. The first digit on the right is the check digit and is never multiplied.

Step 2: Add up each of the odd digits and each of the INDIVIDUAL digits in the PRODUCTS of the even digits.

Step 3: Divide the sum from Step 2 by 10. If it is evenly divisible, the card number is valid

Link to comment
Share on other sites

This topic is 8349 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.