# Credit Card Number validation using Lunh Algorithm

Credit cards or Debit cards are validated by a formula known as “Lunh Algorithm”. It is also known as “Modulus 10” algorithm. It is created by Hens Peter Lunh ( A scientist in IBM).

It is also used to validate IMEI Numbers and National Provider Ind

entifier Number in US.

Lunh Algorithm verify numbers against its check digit (i.e. Last number of credit card). To validate credit card number, it must pass Lunh Algorithm.

**Validate the Credit card using Lunh Alogrithm**

- Step1. Reverse the credit card number e.g.
4211 6880 3434 4563 =3654 4343 0886 1124

- Step 2. Double the every even position digit like.
3 (12) 5 (8) 4 (6) 4 (6) 0 (16) 8 (12) 1 (2) 2 (8)

- Step 3. Make two digit numbers in to a single by adding both digits like (10=1 0=1, 16=(1 6)=7)
3 (12=1 2=3) 5 8 4 6 4 6 0 (16=6 1=7) 8 (12=2 1=3) 1 2 2 8

- Step 4. Get the sum of all numbers and divide them by 10. if the modulus of sum casino online is 0 then credit card number is valid number else credit card number is not valid. e.g.
3 (12=1 2) 5 8 4 6 4 6 0 (16=6 1) 8 (12=2 1) 1 2 2 8=70

mod 70/10 = 0 so this credit card is valid.

**Get check Digit of Credit card number**

- Step 1. Reverse the first 15 digits of credit card number e.g.
4211 6880 3434 456 = 654 4343 0886 1124

- Step 2. Double the every odd position digits. eg.
(12) 5 (8) 4 (6) 4 (6) 0 (16) 8 (12) 1 (2) 2 (8)

- Step 3. Make two digit numbers in to a single by adding both digits like (10=1 0=1, 16=(1 6)=7)
(12=1 2=3) 5 8 4 6 4 6 0 (16=6 1=7) 8 (12=2 1=3) 1 2 2 8

- Step 3. Get the sum of all number and add a digit to the result so that the result is exactly divisible by 10 e.g.
(12=1 2) 5 8 4 6 4 6 0 (16=6 1) 8 (12=2 1) 1 2 2 8=67

In the above exmple we have the sum 67 so I add 3 to it to make it exactly divisible by 10.

so 70 is divisible by 10 and 70-67=3

So 3 is the check digit of this credit card.

Verification of Credit card number in javascript

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | function isCreditCard(CC) { if (CC.length > 19) { alert("You have entered an invalid card"); return false; } sum = 0; mul = 1; l = CC.length; for (i = 0; i < l; i ) { digit = CC.substring(l-i-1,l-i); tproduct = parseInt(digit ,10)*mul; if (tproduct >= 10) sum = (tproduct % 10) 1; else sum = tproduct; if (mul == 1) { mul ; } else { mul--; } } if ((sum % 10) == 0) { alert("Congrats you enter valid card number"); return true; } else { alert("You have entered an invalid card"); return false; } } |

omg!!! Do you have a walkthrough for implementing credit card vergifaction for things like paypal pro? I’m moving from ubercart to commerce for d7 but understanding the process to secure the site for and implement insure cc is just fragmented and well… unfollowable lol sad but true :p

None can doubt the versatility of this article.

You have written a extremely thought-provoking article. Your content speaks to me and I share within your views. numerous writers do not compose genuine material, but you have actually done an ideal profession with this information.

Thanks using the information, I rarely like it.

Definitely believe that which you said. Your favorite reason appeared to be at the web the easiest thing to consider of. I say to you, I definitely get irked even as folks think about issues that they just don’t understand about. You managed to hit the nail upon the top and also defined out the entire thing with no need side effect , folks could take a signal. Will likely be again to get more. Thank you

Any fascinating discussion is worthy of attention, this weblog is extremely nice.

This is a truly good study for me, Must admit that you are 1 of 1 of the right bloggers I actually saw.Thanks for posting this informative article.

It is similar to you study my thoughts! You gaze to understand such a lot associated with this, exactly like you authored the book inside it or something. I do think you could do with some photos they are driving your own information house a bit, but in addition to that, this is superb blog.

hello!,I like your writing very much! proportion we keep up a correspondence more about your post on AOL? I require a specialist on this house to unravel my problem. Maybe that’s you! Taking a look ahead to look you.

You actually make it seem so easy with your presentation but I find this topic to be really something that I think I would never understand. It seems too complicated and very broad for me. I am looking forward for your next post, I will try to get the hang of it!

Fantastic items of your stuff, guy. I have study your things ahead of and you are just as well incredible. I enjoy exactly what you have right here, really like what youre stating and the way you say it. You are making this enjoyable and also you even now manage to help keep it smart. I cant wait around to undergo extra of your stuff. That is really an incredible website.

You could definitely see your enthusiasm in the work you write. The world hopes for more passionate writers such as you who aren’t afraid to mention how they believe. Always follow your heart.

I,myself really like your post so much, hoping you could create more wonderful types

I have just discovered your site and revel in each article. We appreciate your talent.

You are therefore cool! I dont suppose I have learn anything like this before. So great to seek out somebody with some authentic ideas on this topic. realy thank you for starting this particular upward. this web site is one thing thats desired on the internet, someone with a little bit of originality. useful job for getting something a new comer to the net!

It is really a nice and useful piece of info. I?m happy that you simply shared this useful info with us. Please keep us up to date like this. Thanks for sharing.

Love the information here. Adding to my bookmarks. Thank you!

For today, I will learn something new.