Credit Card Validation

John Esak john at valar.com
Mon Jul 18 10:39:51 PDT 2005


Wally (and Richard),
Here is a message from the thread I had started with this credit card
checksum routine. I'm sorry you will have to piece it all together... but it
really is quite a good routine to be used as a CALL table. You must have the
edits shown here also in place. (you may have your own rmsp edit... but
however you do it, I'm sure you can do this yourself.) There are some edits
for expiration date which you may not need... The ones you do need must run
on the actual entered card number first. They do a lot of the important work
for you.  The call table will do all the rest.  Remember my caution about
lines that wrap around... the colons have to be right, 3 per line....

Again, my apologies, but this is all Rick could find in my many archive
folders... the original message *is* somewhere... but not immediately
visible.

John

-----Original Message-----
From: John Esak [mailto:john at valar.com]
Sent: Friday, April 25, 2003 2:40 PM
To: Courtney
Cc: Fplist (E-mail)
Subject: RE: Credit Card Validation


Okay,
Here is a group of edits I used for credit cards. A couple/three that do the
month/year of expiration a few that do the form of the card (Visa, MC, AX)
And the thing that removes the spaces from a field that might have some. Say
someone puts in 4123 1234 5678 1234 it moves it to 4123123456781234 of
course.  The combination of the edits is what helps get things right, first
the rmspcs, then the form, and _then_ you check the checksum with the
processing stub I sent earlier. If all that passes, the card is valid and
you should submit the transaction for payment/credit whatever.

John

Add this to your edit table.

rmspc:[{!" "!}]
N_nospc:{ {rmspc} | [{N}] }
expm:"01"|"02"|"03"|"04"|"05"|"06"|"07"|"08"|"09"|"10"|"11"|"12"
expy:"00"|"01"|"02"|"03"|"04"|"05"|"06"|"07"|"08"|"09"
expym:expy expm
expmy:expm expy
forma:"3" N N N <" "> N N N N N N <" "> N N N N N
formv1:"4" N N N <" "> N N N N <" "> N N N N <" "> N N N N
formv2:"4" N N N <" "> N N N <" "> N N N <" "> N N N
formv:formv1|formv2
formm:"5" N N N <" "> N N N N <" "> N N N N <" "> N N N N
formd:"6" N N N <" "> N N N N <" "> N N N N <" "> N N N N
allcc:forma|formv|formm|formd



> -----Original Message-----
> From: owner-filepro-list at celestial.com
> [mailto:owner-filepro-list at celestial.com]On Behalf Of Courtney
> Sent: Friday, April 25, 2003 1:47 PM
> To: Filepro-List
> Subject: FW: Credit Card Validation
>
>
> Any got an edit like John mentions?
>
> -----Original Message-----
> From: John Esak [mailto:john at valar.com]
> Sent: Friday, April 25, 2003 11:36 AM
> To: Courtney
> Subject: RE: Credit Card Validation
>
>
> you need an edit called n_nospcs that takes away spaces... I
> don't know if I
> can find it or not... I'll look... meanwhile, ask someone on the forum for
> an edit to replace this...
>
> > -----Original Message-----
> > From: Courtney [mailto:courtney at northshoreagency.com]
> > Sent: Friday, April 25, 2003 10:47 AM
> > To: john at valar.com
> > Subject: RE: Credit Card Validation
> >
> >
> > John
> >
> > Many thanks for code...
> >
> > Entered it, but got this message
> > *** A filePro Error Has Occurred ***
> >
> > Line Number: 2
> >
> > declare tightcardnum(19,n_nopsc);tightcardnum=cn
> >                     ^
> > Process contains a syntax error at position indicated.
> >
> > I don't see anything wrong-do u?
> >
> > Hey, its Friday...
> >
> >
> > -----Original Message-----
> > From: owner-filepro-list at celestial.com
> > [mailto:owner-filepro-list at celestial.com]On Behalf Of John Esak
> > Sent: Friday, April 25, 2003 9:27 AM
> > To: Fplist (E-mail)
> > Subject: RE: Credit Card Validation
> >
> >
> >
> > Here is a routine I wrote to check credit card validity. Good
> luck if you
> > can understand it any better than I can now! :-)  Serisoulsy, it may be
> > readable, actually. Be careful about the lines that wrap around
> if you try
> > and read this right into a processsing table. Count the colons...
> > three per
> > line.
> > John
> >
> > chkval:'chkval  check validity of cardnumber::
> > :'removes space from cosmetic card#:declare tightcardnum(19,N_nospc);
> > tightcard
> > num=js:
> > ::declare cardnum;  cardnum=tightcardnum { "":
> > :'cardnum is the compressed (no spaces) credit card number:declare
> > num_of_digits
> > (2,.0); num_of_digits=len(cardnum):
> > ::declare check_digit(1,.0);
> check_digit=mid(cardnum,num_of_digits,"1"):
> > ::declare accumulator(3,.0);  accumulator="":
> > ::declare ct_i(2,.0);  ct_i="1":
> > loop_i:ct_i eq num_of_digits:goto finchk:
> > :(frac(ct_i / "2") gt "0") and (mid(cardnum,num_of_digits - ct_i,"1") ge
> > "5"):ac
> > cumulator=accumulator + ((mid(cardnum,num_of_digits - ct_i,"1") * "2") -
> > "9");
> > ct_i=ct_i + "1";  goto loop_i:
> > :(frac(ct_i / "2") gt "0"):accumulator=accumulator +
> > ((mid(cardnum,num_of_digits
> >  - ct_i,"1") * "2") );  ct_i=ct_i + "1";  goto loop_i:
> > ::accumulator=accumulator + mid(cardnum,num_of_digits - ct_i,"1");
> > ct_i=ct_i +
> > "1";  goto loop_i:
> > finchk:'finchk::
> > ::'show "@accumulator=" < accumulator:
> > ::declare ccnum_is_valid(1,yesno);  ccnum_is_valid="":
> > :check_digit eq ( (accumulator + "10") - mod(accumulator,"10") -
> > accumulator ):c
> > cnum_is_valid="Y":
> > :(check_digit eq "0") and (mod(accumulator,"10") eq
> > "0"):ccnum_is_valid="Y":
> > ::return:
> >
> >
> > > -----Original Message-----
> > > From: owner-filepro-list at celestial.com
> > > [mailto:owner-filepro-list at celestial.com]On Behalf Of Courtney
> > > Sent: Friday, April 25, 2003 8:35 AM
> > > To: Filepro-List
> > > Subject: Credit Card Validation
> > >
> > >
> > > have a question...I seem to recall many years ago I did a check
> > > digit mod-10
> > > (I think) verification of a credit card number...is that still
> > > true?  I have
> > > completely forgotten it, I believe it was something like add
> each odd #
> > > digit to a counter, multiply the even number digit by 2, than add
> > > the digits
> > > from the result to the counter...after all digits added to
> counter, the
> > > result had to be a multiple of 10...am I close?  Any ideas?
> > >
> > > Example (using 5 digits as a example)
> > >
> > > 45678
> > > 				add to counter    counter
> > > 4   					4		4
> > > 5 * 2 = 10 (1 + 0 = 1) 		1		5
> > > 6 					6		11
> > > 7 * 2 = 14 (1 + 4 = 5)		5		16
> > > 8					8		24
> > >
> > > With this example it would fail, but am I doing it right? Is it
> > > still true?
> > > Are there any other methods quicker and/or better?
> > >
> > > Thanks again
> > >
> > > Courtney Karl Seith
> > > North Shore Agency



More information about the Filepro-list mailing list