[U2] Mod10 Credit Card Checksum

2005-12-02 Thread Baker Hughes
Say, has anyone written some code to validate a Credit Card number,
using the Mod10 (nicknamed) or ANSI X4.13 (realname) LUHN formula?  I
was just told today get this installed yesterday, so I'm naturally
looking to see if some kind-hearted fellow MV'ver has something already
written (it is the season for giving ;-) ).

I searched ansi.org and only got hits on meeting agendas - [in session
4.13 discuss blah blah]
I found the previous u2ug posting that used Mod10 to validate a UPC, but
it looks a bit different from algorithm described elsewhere to validate
CCnumbers, and doesn't look agreeable to variable lengths (different you
know based on each card type).

I'm really thankful for U2UG, and glean much from the postings.  I'd
contribute more answers but I've only been at this 14 years and someone
more seasoned invariably gives a thoroughly enlightening response.

TIA.

-Baker
bakerdothughes
atmouser
dotcom
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Mod10 Credit Card Checksum

2005-12-02 Thread Robin Stanley
We have been using this Mod10 code for years. Note - CLEN = LEN(CARD.NUM)

0076 **
0077 ** 
0078 **
0079 ALGO.CHECK:  ** card number algorithm check
0080  CSTR =  ; PTR = 0
0081  FOR I = CLEN TO 1 STEP -1
0082   PTR = PTR + 1
0083   IF MOD(PTR, 2) # 0 THEN MULTI = 1 ELSE MULTI = 2
0084   CSTR = CARD.NUM[I, 1] * MULTI : CSTR
0085  NEXT I
0086  **
0087  CSUM = 0 ; CLEN = LEN(CSTR)
0088  FOR I = 1 TO CLEN
0089   CSUM += CSTR[I, 1]
0090  NEXT I
0091  **
0092  IF NOT((MOD(CSUM, 10) = 0)) THEN
0093   ERR = Invalid card number.
0094  END
0095 RETURN

Robin Stanley

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Baker Hughes
Sent: Friday, December 02, 2005 8:11 AM
To: u2-users@listserver.u2ug.org
Subject: [U2] Mod10 Credit Card Checksum


Say, has anyone written some code to validate a Credit Card number,
using the Mod10 (nicknamed) or ANSI X4.13 (realname) LUHN formula?  I
was just told today get this installed yesterday, so I'm naturally
looking to see if some kind-hearted fellow MV'ver has something already
written (it is the season for giving ;-) ).

I searched ansi.org and only got hits on meeting agendas - [in session
4.13 discuss blah blah]
I found the previous u2ug posting that used Mod10 to validate a UPC, but
it looks a bit different from algorithm described elsewhere to validate
CCnumbers, and doesn't look agreeable to variable lengths (different you
know based on each card type).

I'm really thankful for U2UG, and glean much from the postings.  I'd
contribute more answers but I've only been at this 14 years and someone
more seasoned invariably gives a thoroughly enlightening response.

TIA.

-Baker
bakerdothughes
atmouser
dotcom
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Mod10 Credit Card Checksum

2005-12-02 Thread James F Thompson
  SUBROUTINE CC.VALID(CCN,OK,CTYPE)
*
  OK=0 ; WGT=2 ; SUM=0 ; CCLEN=LEN(CCN)
  DIGIT=0 ; CTYPE=
  CHK.DIGIT=CCN[CCLEN,1] ; MDIGIT=0
  FOR X = CCLEN - 1 TO 1 STEP -1
 CC.D=CCN[X,1]
 IF NOT(NUM(CC.D)) THEN CC.D=-9
 DIGIT=WGT * CC.D
 SUM=SUM + INT(DIGIT / 10) + MOD(DIGIT,10)
 IF WGT = 2 THEN
WGT = 1
 END ELSE
WGT = 2
 END
  NEXT X
  MDIGIT=(10-MOD(SUM,10))
  MDIGIT2=MOD(MDIGIT,10)
  IF MDIGIT2 # CHK.DIGIT THEN
 OK=0
 CTYPE=Invalid Credit Card Number
  END ELSE
 BEGIN CASE
CASE CCN[1,1]=4 AND (CCLEN=13 OR CCLEN=16)
   CTYPE=V
CASE CCN[1,2]=51 AND CCLEN=16
   CTYPE=M
CASE CCN[1,2]=52 AND CCLEN=16
   CTYPE=M
CASE CCN[1,2]=53 AND CCLEN=16
   CTYPE=M
CASE CCN[1,2]=54 AND CCLEN=16
   CTYPE=M
CASE CCN[1,2]=55 AND CCLEN=16
   CTYPE=M
CASE CCN[1,4]=6011 AND CCLEN=16
   CTYPE=D
CASE CCN[1,2]=37 AND CCLEN=15
   CTYPE=AX
CASE CCN[1,2]=34 AND CCLEN=15
   CTYPE=AX
CASE CCN[1,3]=389 AND CCLEN=14
   CTYPE=CB
CASE CCN[1,2]=94 AND CCLEN=14
   CTYPE=CB
CASE CCN[1,2]=95 AND CCLEN=14
   CTYPE=CB
CASE CCN[1,2]=30 AND CCLEN=14
   CTYPE=DC
CASE CCN[1,2]=36 AND CCLEN=14
   CTYPE=DC
CASE CCN[1,3]=381 AND CCLEN=14
   CTYPE=DC
CASE CCN[1,3]=382 AND CCLEN=14
   CTYPE=DC
CASE CCN[1,3]=383 AND CCLEN=14
   CTYPE=DC
CASE CCN[1,3]=384 AND CCLEN=14
   CTYPE=DC
CASE CCN[1,3]=385 AND CCLEN=14
   CTYPE=DC
CASE CCN[1,3]=386 AND CCLEN=14
   CTYPE=DC
CASE CCN[1,3]=387 AND CCLEN=14
   CTYPE=DC
CASE CCN[1,3]=388 AND CCLEN=14
   CTYPE=DC
CASE 1
   CTYPE=
 END CASE
 IF CTYPE =  THEN
OK=0
CTYPE = Invalid Credit Card Type
 END ELSE
OK=1
CTYPE=OCONV(CTYPE,TPAY.TYP;X;;0)
IF CTYPE =  THEN
   OK=0
   CTYPE = Credit Card Type not Accepted
END
 END
  END
*
  RETURN




James F Thompson 
Senior System Analyst 
Cypress Business Solutions 
678.494.9353 x1410
 
[EMAIL PROTECTED] 
www.cypressesolutions.com

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Baker Hughes
Sent: Friday, December 02, 2005 11:11 AM
To: u2-users@listserver.u2ug.org
Subject: [U2] Mod10 Credit Card Checksum

Say, has anyone written some code to validate a Credit Card number,
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Mod10 Credit Card Checksum

2005-12-02 Thread Kevin King
Today's your lucky day.  I have the LUHN check (and much more) written
in Javascript and posted on the web @
http://www.precisonline.com/ccvalidate.html.  Should be no big deal to
translate to U2. 

-Kevin
[EMAIL PROTECTED]
http://www.PrecisOnline.com
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Mod10 Credit Card Checksum

2005-12-02 Thread Gahan, Mick
Baker,

This is pretty old code and it was taken out of production last January,
However, it was working at the point we stopped using it.  Sorry,
there's not much documentation, but I seem to recall that it used the
MOD10 method.

Give it a try and see what happens.

Mick

Mick Gahan
Director, MIS
Metropolitan Community College
Omaha, NE
(402) 457-2402


SUBROUTINE CCP.CHECK.DIGIT(VALID,CARD.NO)

**CARD.NO = '5286309653523638'

* Last updated by ACTIVE (GAHAN) at 16:39:34 on 08/26/1993.

  TEMP.CARD.NO = CARD.NO

  CONVERT ' ' TO '' IN TEMP.CARD.NO
  CONVERT '-' TO '' IN TEMP.CARD.NO
  IF NOT(NUM(TEMP.CARD.NO)) THEN VALID = 0 ; RETURN

  IF MOD(LEN(TEMP.CARD.NO),2) # 0 THEN
 PROGRESSION = '1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1'
  END ELSE
 PROGRESSION = '2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2'
  END
  CONVERT ',' TO @FM IN PROGRESSION

  LAST.DIGIT = TEMP.CARD.NO[1]
  TEMP.CARD.NO = TEMP.CARD.NO[1,LEN(TEMP.CARD.NO)-1]

  PRODUCT = ''
  TEMP.CARD.NO.LENGTH = LEN(TEMP.CARD.NO)
  FOR IDX = 1 TO TEMP.CARD.NO.LENGTH
 TEMP = TEMP.CARD.NO[IDX,1] * PROGRESSIONIDX
 TEMP = TEMP[1,1] + TEMP[2,1]
 PRODUCTIDX = TEMP
  NEXT IDX
  SUM.RESULTS = SUM(PRODUCT)

  IF SUM.RESULTS[1] = 0 THEN
 CHECK.DIGIT = 0
  END ELSE
 CHECK.DIGIT = 10 - SUM.RESULTS[1]
  END

  IF LAST.DIGIT # CHECK.DIGIT THEN
 VALID = 0
  END ELSE
 VALID = 1
  END

  RETURN

END 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Baker Hughes
Sent: Friday, December 02, 2005 10:11 AM
To: u2-users@listserver.u2ug.org
Subject: [U2] Mod10 Credit Card Checksum

Say, has anyone written some code to validate a Credit Card number,
using the Mod10 (nicknamed) or ANSI X4.13 (realname) LUHN formula?  I
was just told today get this installed yesterday, so I'm naturally
looking to see if some kind-hearted fellow MV'ver has something already
written (it is the season for giving ;-) ).
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Mod10 Credit Card Checksum

2005-12-02 Thread Results

Barker,
I haven't needed to know this for the last several years, so I had 
to look it up. This looks right, but you should double check it:


   http://www.epanorama.net/documents/smartcard/magcard.html

   - Chuck LRC Barouch

Baker Hughes wrote:


Say, has anyone written some code to validate a Credit Card number,
using the Mod10 (nicknamed) or ANSI X4.13 (realname) LUHN formula?  I
was just told today get this installed yesterday, so I'm naturally
looking to see if some kind-hearted fellow MV'ver has something already
written (it is the season for giving ;-) ).
 


--

- Charles Barouch
[EMAIL PROTECTED]
(718) 762-3884 x 1
	P. O. Box 540957, 
	Linden Hill, NY 11354-0957

www.KeyAlly.com
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Mod10 Credit Card Checksum

2005-12-02 Thread john reid
Did this a long time ago.  It wont cost much to see if it works.
j
**  SUBROUTINE MOD10CD(NUM1, CDNUM)
M2STR= 
SUM.STRING=
SUM.OPERANDS=
NEXT.HIGH.10=0
INPUT NUM1
LNUM1=LEN(NUM1)
FOR I = LNUM1 TO 1 STEP -2
IF MOD(I,2) = 0 THEN
SUM.STRING-1=NUM1[I,1]
END ELSE
M2STR:=NUM1[I,1]
END
NEXT I
M2STRM=M2STR*2
SUM.OTHER = SUM(SUM.STRING)
NUM.MULT.DIGITS=LEN(M2STRM)
FOR I = 1 TO NUM.MULT.DIGITS
OPERAND=M2STRM[I,1]
SUM.OPERANDS+=OPERAND
NEXT I
FINAL.SUM=SUM.OPERANDS + SUM.OTHER
FINAL.SUM=SUM.OPERANDS + SUM.OTHER
LOOP
UNTIL NEXT.HIGH.10 = FINAL.SUM
NEXT.HIGH.10 += 10
REPEAT
CDNUM = NEXT.HIGH.10 - FINAL.SUM
CRT CDNUM
RETURN


On 12/2/05, Baker Hughes [EMAIL PROTECTED] wrote:
 Say, has anyone written some code to validate a Credit Card number,
 using the Mod10 (nicknamed) or ANSI X4.13 (realname) LUHN formula?  I
 was just told today get this installed yesterday, so I'm naturally
 looking to see if some kind-hearted fellow MV'ver has something already
 written (it is the season for giving ;-) ).

 I searched ansi.org and only got hits on meeting agendas - [in session
 4.13 discuss blah blah]
 I found the previous u2ug posting that used Mod10 to validate a UPC, but
 it looks a bit different from algorithm described elsewhere to validate
 CCnumbers, and doesn't look agreeable to variable lengths (different you
 know based on each card type).

 I'm really thankful for U2UG, and glean much from the postings.  I'd
 contribute more answers but I've only been at this 14 years and someone
 more seasoned invariably gives a thoroughly enlightening response.

 TIA.

 -Baker
 bakerdothughes
 atmouser
 dotcom
 ---
 u2-users mailing list
 u2-users@listserver.u2ug.org
 To unsubscribe please visit http://listserver.u2ug.org/



--
john
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Mod10 Credit Card Checksum

2005-12-02 Thread karlp
Thanks James. This is a project I'm embroiled in, too. Your code worked
right out of the box.

Karl

quote who=James F Thompson
   SUBROUTINE CC.VALID(CCN,OK,CTYPE)
 *
   OK=0 ; WGT=2 ; SUM=0 ; CCLEN=LEN(CCN)
   DIGIT=0 ; CTYPE=
   CHK.DIGIT=CCN[CCLEN,1] ; MDIGIT=0
   FOR X = CCLEN - 1

 stuff deleted... 

-- 
karl

 _/  _/  _/  _/_/_/      __o
_/ _/   _/  _/_/   _-\._
   _/_/_/  _/_/_/ (_)/ (_)
  _/ _/   _/  _/   ..
 _/   _/ arl _/_/_/  _/ earson[EMAIL PROTECTED]

--
IT Director, ATS Industrial Supply, Inc.
http://www.atsindustrial.com
Toll-free: 800-789-9300 x29
Direct2Desk: 801-978-4429
Facsimile: 801-972-3888
--
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Mod10 Credit Card Checksum

2005-12-02 Thread Baker Hughes
Thanks to each of you for the good postings. You've got me going now.  I
may miss their target date of yesterday but Tuesday is looking pretty
good.  Now, if anyone has an algorithm to speed up the QA dept things
will shake out rather nicely.  We'll be using something which follows
very closely on James Thompson's subroutine.  I wasn't going to check
the prefix against card type, but before I got the final END on my
subroutine, more requirements came in !-\

-Baker
bakerdothughes
atmouser
dotcom
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/