
Credit Card validation
hello,<BR><BR>this is sudheer. i am into a website which requires to validate credit cards....<BR><BR>can anyone suggest how i can do that. if possible a sample code of how its done......i really dont have any idea of how to do it.<BR><BR>hoping for some help.....thanks in advance....<BR><BR>sudheer.

RE: Credit Card validation
Hello Sudheer,<BR><BR>If you want to validate that a number meets the credit card checksum criterion, then I will post that code for you. If, however, you are asking how to validate that a credit card is real, that it is not stolen, that it has available credit, that a particular charge is allowed, and then you would like to actually place a charge on that card, then the answer could not occur until you gave us some more details.<BR><BR>For example, do you (or does your client) already have a merchant account? If so, with whom? Which credit card processor(s) does that merchant account support?<BR>

RE: Credit Card validation
hi ballet <BR><BR>thx for the reply. i just need to validate that a number meets the credit card checksum....i will not do any monitory operations with the card.....<BR><BR>pls send me the code if u can. <BR>once again thank u very much and awaiting ur mail.....<BR>

RE: Credit Card validation
<%<BR><BR> Dim CreditCardNumber<BR> Dim ExpireDate<BR><BR> 'This is the function that checks the date<BR> '<BR><BR> Function GoodDate()<BR> GoodDate = True<BR> If Not IsDate(ExpireDate) Then<BR> GoodDate = False<BR> Else<BR> currdate = Month(Now()) & " " & Year(Now())<BR> If DateValue(ExpireDate) < DateValue(currdate) Then<BR> GoodDate = False<BR> End If<BR> End If<BR> End Function<BR><BR><BR><BR><BR> 'This function looks for numbers in the card number string, thereby<BR> 'removing all non numeric characters<BR> '<BR> Function CleanString(ByVal CardNo)<BR> dim strLen<BR> dim strCounter<BR> dim strClean <BR> dim strDirty<BR> <BR> strDirty = Trim(CardNo)<BR> strLen = Len(strDirty)<BR> strClean = ""<BR> <BR> For strCounter = 1 to strLen<BR> If Asc(Mid(strDirty,strCounter,1)) < 58 AND Asc(Mid(strDirty,strCounter,1)) > 47 Then<BR> strClean = strClean & Mid(strDirty,strCounter,1)<BR> End If<BR> Next<BR> CleanString = strClean<BR> End Function<BR><BR><BR><BR> Function VerifyCardMod(ByVal CardNo)<BR> Dim card<BR> Dim Vcard(21)<BR> Dim Xcard<BR> Dim x<BR> Dim xx<BR> Dim y<BR> Dim LengthOK<BR> <BR> card = CardNo<BR><BR> for xx = 1 to Len(card)<BR> Vcard(xx) = Abs(Asc(Mid(Card,xx,1)))<BR> Next<BR><BR>&nbs p;x = Len(card)1<BR> Xcard = 0<BR><BR> If (Len(card) Mod 2)=0 then<BR> for xx = 1 to (Len(card)1)<BR> if (x Mod 2)=1 then<BR> y = ((Vcard(x)48)*2)<BR> else y = (Vcard(x)48) <BR> End if <BR> if y >= 10 then y = ((y10)+1) end if<BR> Xcard = (Xcard + y)<BR> x = x1<BR> Next<BR> Else<BR> for xx = 1 to (Len(card)1)<BR> if (x Mod 2)=1 then<BR> y = (Vcard(x)48)<BR> else y = ((Vcard(x)48)*2)<BR> End If<BR> if y >= 10 then y = ((y10)+1) end if<BR> Xcard = (Xcard+y)<BR> x = x1 <BR> Next<BR> End if<BR> x = (10(Xcard mod 10))<BR> if (x = 10) then x = 0 End If<BR> if x = (Vcard(Len(card))48) then VerifyCardMod = Mid(Card,1,1) else VerifyCardMod = 0 End If<BR><BR> End Function<BR><BR><BR><BR><BR> '''& #039 TESTING HARNESS '''''''''<BR>& nbsp;Dim TheCardType<BR> Dim CheckCard<BR><BR> CheckCard = ""<BR> 'The following items should be grabbed from your order form. This page should either store the<BR> 'order in a database after checking or whatever procedure you desire to use.<BR><BR> ExpireDate = "06/00"<BR> TheCardType = "master" '<Use amex, visa, master or disc here<BR> CreditCardNumber = "5000 0000 0000 0000" '<Place your credit card number here<BR><BR> 'Processing calls start here<BR><BR> if GoodDate() then 'the date passed the test<BR><BR> CreditCardNumber = Replace(CreditCardNumber, "", "") 'Clean up any messy card numbers first<BR> CeditCardNumber = Replace(CreditCardNumber, " ", "")<BR> CreditCardNumber = CleanString(CreditCardNumber)<BR><BR> CheckCa rd = CStr(VerifyCardMod(CreditCardNumber)) 'Check the MOD 10 checksum of card<BR><BR> Select Case TheCardType<BR> Case "amex"<BR> verified = (CheckCard = "3") 'is good American express number<BR> TheCardType = " American Express "<BR> Case "visa"<BR> verified = (CheckCard = "4") 'is good Visa number<BR> TheCardType = " Visa "<BR> Case "master" <BR> verified = (CheckCard = "5") 'is good MasterCard number<BR> TheCardType = " MasterCard "<BR> Case "disc"<BR> verified = (CheckCard = "6") 'is good Discovery card number<BR> TheCardType = " Discovery "<BR> Case Else<BR> Verified = False 'Is not a valid card number<BR> TheCardType = " "<BR> End Select <BR><BR> if Verified then%><BR><BR> Valid<%=TheCardType%> card number<BR> <BR> <%else%><BR><BR>&n bsp;Bad<%=TheCardType%>card number<BR> <BR> <%end if<BR> Else%><BR> <BR> Bad Date<BR> <BR> <%end if%><BR><BR><BR><BR>

RE: Credit Card validation
How fantasically useful  I always wanted to know how that checksum worked! Now all I need is a bit of reverseengineering and I can start generating my own card numbers... <laugh type="evil" /><BR><BR>Dunc

RE: Credit Card validation
hi really that was good. i now have an idea what to do.<BR><BR>but still i would like u to explain me the VerifyCardMod(ByVal CardNo) function. i didnt undertand it completely. i apalogize if i am troubling u for this. i am totally new to this. <BR><BR>hoping for an explanation.<BR><BR>regards,<BR><BR>sudheer.

RE: Credit Card validation
You mean you want me to explain the entire routine?<BR><BR>Well... ok...<BR><BR>This routine works using an algorithm called the LUHN method (that has come to commonly be called the 'modulo10' or 'check 10' algorithm). It works like this:<BR><BR>The following steps are required to validate the primary account nummber:<BR><BR><BR>Step 1: Double the value of alternate digits of the primary account number beginning with the second digit from the right (the first righthand digit is the check digit.) <BR><BR>Step 2: Add the individual digits comprising the products obtained in Step 1 to each of the unaffected digits in the original number. <BR><BR>Step 3: The total obtained in Step 2 must be a number ending in zero (30, 40, 50, etc.) for the account number to be validated. <BR><BR>For example, to validate the primary account number 49927398716: <BR><BR>Step 1: <BR><BR> 4 9 9 2 7 3 9 8 7 1 6<BR> x2 x2 x2 x2 x2 <BR><BR> 18 4 6 16 2<BR><BR><BR><BR><BR><BR>Step 2: 4 +(1+8)+ 9 + (4) + 7 + (6) + 9 +(1+6) + 7 + (2) + 6 <BR><BR>Step 3: Sum = 70 : Card number is validated <BR><BR>Note: Card is valid because the 70/10 yields no remainder. <BR><BR><BR>Here is some more Credit Card info that may help you:<BR><BR>CARD TYPE Prefix Length<BR>========== ======= ==========<BR>MASTERCARD 5155 16<BR>VISA 4 13 or 16<BR>AMEX 34/37 15<BR>Diners Club/Carte Blanche 300305/36/38 14<BR>Discover 6011 16<BR>enRoute 2014/2149 15<BR>JCB 3 16<BR>JCB 2131/1800 15<BR><BR>

RE: Credit Card validation
hoooooooooooooo it works and i understood all the things. thank you very much. i really wonder how such logics are developed. thats great.<BR><BR>well i think i really have to take ur guidance when ever i require help. if u dont mind me asking u i would like to have ur email address. just incase i get some doubts i want to contact u.<BR>well thats all if u r interested. any way thanks a lot once again.<BR><BR>have a nice day.<BR><BR>regards,<BR>sudheer.

RE: Credit Card validation
The purpose of a checksum like this is not mainly to verify a credit card number, but to insure that a human being did not transpose two numbers, or type a number incorrectly. The reason that checksums 'generally' work is that if even one number in the the main sequence changes, it 'is fairly certain' that the checksum will be wildly different. Obviously, since it uses one digit, the LUHN check is NOT a very good example of a checksum algorithm (change any number(s) and you STILL have a one in ten chance of having a correct checkdigit). So it's not too difficult to fool this algorithm.<BR><BR>You can always post messages here and I will answer if I am around. :)
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

