Function name: CardChek() Purpose: Verifies proper entry of credit card account numbers. Written by: Mike Coticchio Compuserve: 74740,2611 Internet : 74740.2611@compuserve.com Notice: Copyright (c) Michael Coticchio, 1993. All rights reserved. Donated to the CA-Clipper programming community for its free use. Author does not warrant the fitness of this function for any application and assumes no liability for damages resulting from the use or misuse of this function. Use of this function is solely at your own risk. Compiler version: CA-Clipper 5.2b Syntax: CardChek(cCardNum) --> nCardType Arguments: cCardNum - a credit card number to be tested Returns: a numeric value as follows: -1 - number is invalid 0 - unknown card type (account number valid) 1 - American Express 2 - Visa 3 - MasterCard 4 - Discover 5 - Carte Blanche 6 - Diners Club 7 - JCB Description: CardChek() is a function useful in POS applications which handle credit-card processing. The function serves two purposes: 1. Perform check digit calculation on credit card numbers. This will help trap keying errors that frequently occur when a credit card number is manually entered at the POS terminal. NOTE: the function DOES NOT and CANNOT indicate whether an account number is valid - only whether the account number itself passes an internal check digit test. Do NOT assume that a credit card is legitimate just because CardChek() tells you the number is OK. Accounts can be invalid for a number of reasons; it is quite possible for invalid account numbers to generate correct check digit calculations. 2. Determine the type of credit card being used. This is especially useful if the credit card is being read by a magnetic stripe reader, since your POS application will be able to auto-detect credit cards rather than having the sales clerk select (sometimes incorrectly) the type of card. CardChek() recognizes 7 major credit cards. Example: function test() local cCard, nResult local aCards := {"AmEx", "Visa", "MasterCard", "Discover",; "Carte Blanche", "Diners", "JCB"} cCard := space(16) @ 5, 10 say "Card number:" get cCard read if !empty(cCard) nResult := CardChek(cCard) if nResult < 0 @ 7,10 say "Card is invalid" elseif nResult == 0 @ 7,10 say "Unknown card type" else @ 7, 10 say "Card type: " + aCards[nResult] endif endif return nil