Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Credit Card Identifyers


dreamscape

Recommended Posts

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 function validate() replace all the credit card identifying eregs with these ones:

 

      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';

     }

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Link to comment
Share on other sites

God only knows how many orders we've been turning away becasue of this, lol.

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

it would probably be best if you have some code that detects that it is unknown and then tells the user to double check the number before proceeding. The reason for the CC checking in the first place is to stop people accidently putting in an invalid number and causing your shop added time by having to contact the customer for the corrected number.

 

 

My point being - you are going to get a lot more mistyped credit cards getting through.

Link to comment
Share on other sites

it would probably be best if you have some code that detects that it is unknown and then tells the user to double check the number before proceeding. The reason for the CC checking in the first place is to stop people accidently putting in an invalid number and causing your shop added time by having to contact the customer for the corrected number.

 

 

My point being - you are going to get a lot more mistyped credit cards getting through.

 

No we aren't.

 

All I changed was the credit card identifyers. Nothing in the MOD 10 checksum has changed, and if you put in an invalid CC number, it will still give the OSC "invalid cc number" error.

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Link to comment
Share on other sites

to expand on my previous statement, credit card validation scripts break down like this:

 

- Try to identify the card type, if possible (Visa, MC, AMEX, etc)

- Check the cards expiration date has not passed

- Run the number through a MOD 10 checksum for a quick check for a valid cc number

 

Again, all I changed here is the part where it tries to identify the card type. Nothing in the MOD 10 checksum is affected.

 

Again, the point of the card identifyers is to try to identify the card if possible. The identifyers are not to say which card types you do and don't accept. That is my personal belief anyway.

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Link to comment
Share on other sites

its a great find!

 

and as wizardsandwars stated, who knows how many transactions have been lost... if we only had this a couple of years ago, but now on with the future 8)

Link to comment
Share on other sites

I went one stage further and disabled the mod10 test too - those of us in the UK will know that some Switch and Solo cards are non-compliant with it.

 

It causes the odd fake order, but it better than losing genuine orders due to paranoid validation.

Link to comment
Share on other sites

  • 2 weeks later...

Hello,

 

I nedd to add local credit cards to cc_validation.php.

My problem is that i don?t understand the rules to add it (ereg('^(3[0-9]{4}|2131|1800)[0-9]{11}$', ??)

I need to add a rule to add one of the local credit cards that start with numbers 589892

 

Thanks.

Link to comment
Share on other sites

I nedd to add local credit cards to cc_validation.php.

My problem is that i don?t understand the rules to add it (ereg('^(3[0-9]{4}|2131|1800)[0-9]{11}$', ??)

I need to add a rule to add one of the local credit cards that start with numbers 589892

ereg('^589892[0-9]{10}$', $this->ccnumber) would be the one for a 16 digit card. I got the 10 in {} by subtracting 6 (the number of digits in 589892) from 16. If you needed 13 digits, you would subtract 6 from 13 and get 7, with which you would replace the 10.

 

Hth,

Matt

Link to comment
Share on other sites

ereg('^589892[0-9]{10}$', $this->ccnumber) would be the one for a 16 digit card. I got the 10 in {} by subtracting 6 (the number of digits in 589892) from 16. If you needed 13 digits, you would subtract 6 from 13 and get 7, with which you would replace the 10.

 

Hth,

Matt

Thanks for your reply, i add the lines succefully, but when order a product with a 16 digit card that start with 589892 they say "The credit card number entered is invalid.<br>Please check the number and try again."

Link to comment
Share on other sites

Does it pass the checksum. I.e. do the digits add up correctly?

 

I assume you have a block of code that looks like this:

} elseif (ereg('^589892[0-9]{10}$', $this->cc_number)) {

 $this->cc_type = 'Local';

Try adding a

return 0;

at the end of the cc_type line. If that works, it is having problems with the other validations. Confirm that all the values are good (Note: if 4111 1111 1111 1111 is a valid CC number, then 4111 1111 1111 1112 is not with the other cards mentioned.) If you are running the cards manually, you can leave that return 0 there and verify the local cards when you are processing them.

 

Hth,

Matt

Link to comment
Share on other sites

I add "return 0" but the same error appear.

Now, i change return 0 to "return 1" and all works ok.

I check if the others cards function and all seems to work ok.

What the difference betwen return 0 and return 1?

 

Thanks[/code]

Link to comment
Share on other sites

return 1 would be correct. I read the comments rather than the code. The code clearly returns a 1 (true would probably work as well) on success. The comments implied a 0 to me until I read the code. My bad.

 

Good luck,

Matt

Link to comment
Share on other sites

  • 4 weeks later...

thanks added this nice little feature all though i can accept cc yet accept through paypal...

 

any good suggestions for a merchant account for a super small business??

Link to comment
Share on other sites

few question

in the original cc_validation.php

 

function validate() ended with

return -1;

 

should be this sostituted with

 

$this->cc_type = 'Unknown';

 

More question i use only Mastercard and Visa how shoul look like the function validate()...and more can i change type = 'Unknown'; with

type = 'Type ofCard Not accepted';

 

let me know

Link to comment
Share on other sites

  • 1 year later...

Cheers to the creator of these new reg's! Thankyou very much - I have been searching for this for days!

Link to comment
Share on other sites

  • 5 weeks later...

I have 2 stores that I only want to accept VISA or MC and need to know how to set this up also. Did you find a answer to your post cistablue?

 

few question

in the original cc_validation.php

function validate()  ended with

return -1;

should be this sostituted with

$this->cc_type = 'Unknown';

More question i use only Mastercard and Visa how shoul look like the function validate()...and more can i change type = 'Unknown'; with

type = 'Type ofCard Not accepted';

let me know

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...