Business::CCCheck - collection of functions for checking credit card numbers
use Business::CCCheck qw( @CC_months CC_year CC_expired CC_is_zip CC_is_name CC_is_addr CC_clean CC_digits CC_oldtype CC_parity CC_typGeneric CC_typDetail CC_format );
This module checks the validity of the numbers and dates for a credit card entry, including the parity of the CC number itself.
An array of 3 character text months. i.e. Jan, Feb....
Returns the localtime calendar year.
Returns true if card is expired or month year has bad fromat else false
Check for valid zip code, returns false or the zipcode.
Check for a name string greater than three characters. Return false if short, otherwise return the name.
Check for a string containing at least 3 words and one endline. Return false if short, otherwise return the address.
Remove blanks and dashes, verify numeric content. Returns false if invalid characters are present, otherwise the cleaned credit card number.
Pre-process with CC_clean.
Returns false if the card number fails the check digit match (except for enRoute which does not require a check digit) otherwise returns exact text identifying the card issuer that is one of:
MasterCard VISA AmericanExpress DinersClub/Carteblanche Discover enRoute JCB
Checks number of digits in card number.
Performs the number -> name conversion for CC_digits and checks number of digits in card number.
returns false if it can not convert.
Performs a credit card number parity check for CC_digits. This is the same as
CC_luhn_valid(), apart from for 'enRoute' cards, which do not have a check digit. For 'enRoute' cards
CC_parity() always returns true.
Performs a strict LUHN check on a credit card number, and returns true if the number has a valid check digit, false otherwise.
Returns a text string describing the type of credit card or 'false' if no indentification can be made. Checks if type is in '%enRoute' or '%CCprimary', similar to Card Types below.
Does NOT check the number of digits in the card number.
Returns detailed description of card type as it appears in %CCsecondary, %CCprimary, %enRoute... or 'false' if the card number can not be identified.
Pre-process with CC_clean, CC_digits.
Returns the credit card number as a group of quadruples separated by spaces. The trailing (right hand) group will contain any remaining non-quad number set.
MOD10 Check Digit calculation
Credit Card Validation - Check Digits
This document outlines procedures and algorithms for Verifying the accuracy and validity of credit card numbers. Most credit card numbers are encoded with a "Check Digit". A check digit is a digit added to a number (either at the end or the beginning) that validates the authenticity of the number. A simple algorithm is applied to the other digits of the number which yields the check digit. By running the algorithm, and comparing the check digit you get from the algorithm with the check digit encoded with the credit card number, you can verify that you have correctly read all of the digits and that they make a valid combination.
Possible uses for this information:
When a user has keyed in a credit card number (or scanned it) and you want to validate it before sending it our for debit authorization. When issuing cards, say an affinity card, you might want to add a check digit using the MOD 10 method.
LUHN Formula (Mod 10) for Validation of Primary Account Number
The following steps are required to validate the primary account number:
Double the value of alternate digits of the primary account number beginning with the second digit from the right (the first right--hand digit is the check digit.)
Add the individual digits comprising the products obtained in Step 1 to each of the unaffected digits in the original number.
The total obtained in Step 2 must be a number ending in zero (30, 40, 50, etc.) for the account number to be validated.
For example, to validate the primary account number 49927398716:
Note: Card is valid because the 70/10 yields no remainder.
The validation applied (last known date 3/96) is the so called LUHN Formula (Mod 10) for Validation of Primary Account Number Validation criteria are:
1. number prefix 2. number of digits 3. mod10 (for all but enRoute which uses only 1 & 2) ... according to the following list of example criteria: Card Type Prefix Length Check-Digit Algoritm MC 51 - 55 16 mod 10 VISA 4 13, 16 mod 10 AMX 34, 37 15 mod 10 Diners Club / 300-305, 36, 38 14 mod 10 Carte Blanche Discover 6011 16 mod 10 enRoute 2014, 2149 16 - any - JCB 3 16 mod 10 JCB 2131, 1800 15 mod 10
Copyright 2001 - 2011, Michael Robinton <firstname.lastname@example.org>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Michael Robinton, <email@example.com>