File: read_credit_validation_class.txt

Recommend this page to a friend!
  Classes of kostas gougakis  >  Shopping basket with MySQL connection  >  read_credit_validation_class.txt  >  Download  
File: read_credit_validation_class.txt
Role: Documentation
Content type: text/plain
Description: documentation about credit_validation class
Class: Shopping basket with MySQL connection
Shopping basket stored in a MySQL database
Author: By
Last change:
Date: 15 years ago
Size: 3,668 bytes


Class file image Download
  The credit_card class provides methods for cleaning, validating and   
     identifying the type of credit card number.         
     credit_card::clean_no() method                                        
     Strips all non-numeric characters from the passed value and returns   
     an integer.  This method is called by the other methods in the        
     credit_card class.                                                    
     USAGE EXAMPLE:                                                        
     $cc_no ="5454 5454 5454 5454"; // Has spaces for readability          
     $cleaned_cc_no = credit_card::clean_no ($cc_no);                      
     print $cleaned_cc_no; // Displays 5454545454545454                    
     credit_card::identify() method                                        
     Finds the type of credit card (Mastercard, Visa, etc...) based on     
     the length and format of the credit card number.  The method can      
     identify American Express, Diners Club/Carte Blanche, Discover,       
     enRoute, JCB, Mastercard and Visa cards.                              
     USAGE EXAMPLE:                                                        
     $cc_no ="5454 5454 5454 5454";                                        
     print credit_card::identify ($cc_no); // Returns "Mastercard"         
     credit_card::validate() method                                        
     Validate a credit card number using the LUHN formula (mod 10).        
     Note that many other kinds of card and account numbers are based on   
     the LUHN algorith - including Canadian Social Insurance Numbers.      
     USAGE EXAMPLE:                                                        
     $cc_no ="5454 5454 5454 5454";                                        
     print credit_card::validate ($cc_no); // Returns TRUE                 
     credit_card::check() method                                           
     The check() method validates and identifies a credit card, returning  
     an array. Indexes 0 and 'valid' will contain TRUE if the card number  
     is valid (FALSE if it isn't), while indexes 1 and 'type' will         
     the type of card (if known). The presence of the numeric keys allows  
     the method to be used with the list() function.                       
     USAGE EXAMPLE:                                                        
     $cc_no ="4111 1111 1111 1111";                                        
     list ($valid, $type) = credit_card::check ($cc_no);                   
     print $valid; // Displays 1 (TRUE)                                    
     print $type;  // Displays "Visa"                                 

For more information send a message to info at phpclasses dot org.