Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages | Examples

CreditCardValidationSolution Class Reference

Inheritance diagram for CreditCardValidationSolution:

tx_commerce_ccvs_lib List of all members.

Public Member Functions

 validateCreditCard ($Number, $CheckNumber, $Language='en', $Accepted='', $RequireExp='N', $Month='', $Year='')
 getCreditCardType ()

Public Attributes

 $CCVSNumber = ''
 $CCVSNumberLeft = ''
 $CCVSNumberRight = ''
 $CCVSType = ''
 $CCVSExpiration = ''
 $CCVSError = ''

Member Function Documentation

CreditCardValidationSolution::getCreditCardType  ) 
 

CreditCardValidationSolution::validateCreditCard Number,
CheckNumber,
Language = 'en',
Accepted = '',
RequireExp = 'N',
Month = '',
Year = ''
 

Ensures credit card information is keyed in correctly.

Checks that the length is correct, the first four digits are within accepted ranges, the number passes the Mod 10 / Luhn checksum algorithm and that you accept the given type of card. It also determines the card's type via the number's first four digits.

The procedure has the option to check the card's expiration date.

Error messages are internationalized through use of variables defined by files in the ./language subdirectory. These files are named after their ISO 639-1 two letter language code. The language used depends on the code put in the $Language parameter.

Just to be clear, this process does not check with banks or credit card companies to see if the card number given is actually associated with a good account. It just checks to see if the number matches the expected format.

Warning: this function uses exact number ranges as part of the validation process. These ranges are current as of 30 July 2002. If presently undefined ranges come into use in the future, this program will improperly deject card numbers in such ranges, rendering an error saying "First four digits indicate unknown card type." If this happens while entering a card and type you KNOW are valid, please contact us so we can update the ranges.

This function requires PHP to be at version 4.0 or above.

Please make a donation to support our open source development. Update notifications are sent to people who make donations that exceed the small registration threshold. See the link below.

Credit Card Validation Solution is a trademark of The Analysis and Solutions Company.

Several people deserve praise for the Credit Card Validation Solution. I learned of the Mod 10 Algorithm in some Perl code, entitled "The Validator," available on Matt's Script Archive, http://www.scriptarchive.com/ccver.html. That code was written by David Paris, who based it on material Melvyn Myers reposted from an unknown author. Paris credits Aries Solis for tracking down the data underlying the algorithm. I pruned down the algorithm to it's core components, making things smaller, cleaner and more flexible. Plus, I added the expiration date checking routine. My first attemts at this were in Visual Basic, on which Allen Browne and Rico Zschau assisted. Neil Fraser helped a bit on the Perl version. Steve Horsley, Roedy Green and Jon Skeet provided tips on the Java Edition.

Parameters:
string $Number the number of the credit card to validate.
string $Language the ISO 639-1 two letter code of the language for error messages.
array $Accepted credit card types you accept. If not used in function call, all known cards are accepted. Set it before calling the function:
$A = array('Visa', 'JCB');
Known types:
  • American Express
  • Australian BankCard
  • Carte Blanche
  • Diners Club
  • Discover/Novus
  • JCB
  • MasterCard
  • Visa
string $RequireExp should the expiration date be checked? Y or N.
integer $Month the card's expiration month in M, 0M or MM foramt.
integer $Year the card's expiration year in YYYY format.
Returns:
boolean TRUE if everything is fine. FALSE if problems.
Version:
Name
Author:
Daniel Convissor <danielc@AnalysisAndSolutions.com> The Analysis and Solutions Company, 2002-2003 http://www.loc.gov/standards/iso639-2/langcodes.html http://www.AnalysisAndSolutions.com/donate/ http://www.AnalysisAndSolutions.com/software/license.htm Simple Public License


Member Data Documentation

CreditCardValidationSolution::$CCVSError = ''
 

CreditCardValidationSolution::$CCVSExpiration = ''
 

CreditCardValidationSolution::$CCVSNumber = ''
 

CreditCardValidationSolution::$CCVSNumberLeft = ''
 

CreditCardValidationSolution::$CCVSNumberRight = ''
 

CreditCardValidationSolution::$CCVSType = ''
 


The documentation for this class was generated from the following file:
Generated on Sun Jan 13 23:12:14 2008 for tx_commerce by  doxygen 1.4.4