Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How do I accept different 'credit card' #?


Guest

Recommended Posts

Hi all!

 

I am attempting to get osC to accept our business account card numbers by modifying cc_validation.php in includes/classes/, however no matter what I do it always rejects the card number at the check out.

 

Can ask for any ideas?

 

Thanks!

 

Will

Link to comment
Share on other sites

Just adding/changing the regular expression test for the number formats is not enough.

 

Does your business account number follow the "Mod 10 / Luhn checksum algorithm" that the cc_validation.php also perfoms? If not then that's why its getting rejected. You may need to do a bit more coding to bypass the Luhn check at the end of cc_validation.php.

 

HTH

Tom

Link to comment
Share on other sites

Hi,

 

Thanks for the reply!

 

Unfortunatley the account numbers don't be following Mod10.

 

Do you know how I would get around the Mod10 validation check?

 

Thanks

 

 

Will

Link to comment
Share on other sites

You'll need to change cc_validation.php. Here's where the code is and a first look at what I'd try. I haven't tested any of this so beware.

 

Change the validate funtion from

 

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

 

and add your special account number and return before the call to the Luhn validation call.

 

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

 

Good Luck

Tom

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...