Credit Card Identifyers

dreamscape <[email protected]> 24 Jul 2003 02:44:41 -0000
Newsgroups gmane.comp.web.oscommerce.tips
Message-ID <b28baee4fa160a8a5ca8759ea2e48b6f@osCommerce-Forums>
This message was sent from: Tips and Tricks
http://forums.oscommerce.com/viewtopic.php?p=200985#200985
----------------------------------------------------------------

Here are some better credit card identifyers I have found.  The stock ones in osCommerce do not take Visa that begins with 4264 and do not accept MasterCards that begin with 5516 (there may be others but we have discovered these 2 thus far).  Also, I eleminated the error it returns if it cannot identify the credit card.  Whether or not the type of credit card is accepted or rejected should be a decision for the credit card processor and not one made by osCommerce.  If it cannot recognize the card, it will just display "unknown" as the card type.

I have tested these new identifyers and they do accept Visas starting with 4264 and MasterCards beginning with 5516.

file: catalog /includes/classes/cc_validation.php

in [i]function validate()[/i] replace all the credit card identifying eregs with these ones:

[code]      if (ereg('^4(.{12}|.{15})$', $this->cc_number)) {
        $this->cc_type = 'Visa';
      } elseif (ereg('^5[1-5].{14}$', $this->cc_number)) {
        $this->cc_type = 'Master Card';
      } elseif (ereg('^3[47].{13}$', $this->cc_number)) {
        $this->cc_type = 'American Express';
      } elseif (ereg('^3(0[0-5].{11}|[68].{12})$', $this->cc_number)) {
        $this->cc_type = 'Diners Club';
      } elseif (ereg('^6011.{12}$', $this->cc_number)) {
        $this->cc_type = 'Discover';
      } elseif (ereg('^(3.{15}|(2131|1800).{11})$', $this->cc_number)) {
        $this->cc_type = 'JCB';
      } elseif (ereg('^5610.{12}$', $this->cc_number)) { 
        $this->cc_type = 'Australian BankCard';
      } else {
        $this->cc_type = 'Unknown';
      }[/code]