How Can You Determine The Type Of Credit Card Number

geekerhub

Updated on:

Understanding Credit Card Numbers and PANs

PAN, or Primary Account Number, is the term used to describe the credit/debit card number. IINs, or Issuer Identification Numbers, were once known as BINs, or Bank Identification Numbers, therefore you may see references to that terminology in some papers. The first six digits of the PAN are taken from the IIN, or Issuer Identification Number, belonging to the issuing bank. These six digits can be used to identify the type of card from the number thanks to ISO/IEC 7812, an international standard.

Credit Card Number Format

Despite the fact that the genuine ISO/IEC 7812 database is not accessible to the general public, there exist unofficial lists that are both paid for and unpaid, including those found on Wikipedia.

Anyhow, you may use a regular expression like the ones shown below to determine the type from the number

Visa : ^4[0-9]{6,}$ Numbers on Visa cards begin with a 4.

MasterCard : ^5[1-5][0-9]{5,}|222[1-9][0-9]{3,}|22[3-9][0-9]{4,}|2[3-6][0-9]{5,}|27[01][0-9]{4,}|2720[0-9]{3,}$Before 2016, MasterCard numbers began with the digits 51 through 55; however, this will only identify credit cards issued through the MasterCard system; additional cards that are issued through the system but do not fall within this IIN range can be found. They will include digits in the range (222100-272099) in 2016.

American Express : ^3[47][0-9]{5,}$The first two digits of an American Express card are 34 or 37.

Diners Club : ^3(?:0[0-5]|[68][0-9])[0-9]{4,}$ Numbers on Diners Club cards start with 300 through 305, 36, or 38. There are 16-digit Diners Club cards that start with the number 5. These should be handled like a MasterCard because they are a joint venture between Diners Club and MasterCard.

Discover : ^6(?:011|5[0-9]{2})[0-9]{3,}$ Discover card digits start with either 6011 or 65.

JCB : ^(?:2131|1800|35[0-9]{3})[0-9]{3,}$ JCB cards have a 2131, 1800, or 35 prefix.

The most significant example is that of Maestro cards, which are widely dispersed throughout the number space due to the fact that many of them were issued from other banks’ IIN ranges and therefore do not reside in the IIN range for MasterCard (which runs from 51 to 55). as a result, It could be most secure to assume that any card you accept that isn’t of another sort is a MasterCard.

Important : card numbers might have different lengths; for example, Visa has previously issued cards with 13- and 16-digit PANs. As of right now, according to Visa’s documentation, it may or may not have issued numbers with a range of 12 to 19 digits. As a result, you shouldn’t check the card number’s length other than to make sure it has at least 7 digits (for a whole IIN plus one check digit, which should match the value predicted by the Luhn algorithm).

One more tip: remove all whitespace and punctuation from the input before processing a cardholder PAN. Why? Due to the fact that it is frequently much simpler to input the digits in groups, much like they are shown on the front of a real credit card, i.e.

how they’re displayed on the front of an actual credit card, i.e.

4444 4444 4444 4444

to enter correctly is considerably simpler than

4444444444444444

It serves no purpose to reprimand the user for entering characters that aren’t appropriate in this situation.

This also means that you should make sure that your entry fields can accommodate at least 24 characters, as users who enter spaces will run out of space. I would advise making the field large enough to display 32 characters and allow up to 64; this will give you plenty of opportunity to grow.

Here is an image that provides some additional context:

Type Of Credit Card Number

Read Also : Install WordPress From Development To Production

Leave a Comment