What do we actually mean when we say "validate a credit card number"?

validating credit card-41

500013642282873 and the value of every second digit is doubled: 5 0 0 0 1 3 6 4 2 2 8 2 8 7 3 x2 x2 x2 x2 x2 x2 x2 ——————————————- 0 0 6 8 4 4 14 The values of the numbers that resulted from multiplying every second digit by two are added together (i.e.

in our example above, multiplying the 7 by two resulted in 14, which is 1 + 4 = 5).

The result of these additions is added to the value of every digit that was not multiplied (i.e.

As well as passing the Mod 10 algorithm, a credit card number must also pass several different formatting rules.

A list of these rules for each of the six most popular credit cards is shown below: As mentioned earlier, in this article we will create a PHP class that will hold the details of a credit card number and expose a function that indicates whether or not the number of that credit card is valid (i.e. Before we create that class however, let’s look at how the Mod 10 algorithm works.

There are three steps that the Mod 10 algorithm takes to determine whether or not a credit card number is valid.

We will use the valid credit card number 378282246310005 to demonstrate these steps: The number is reversed and the value of every second digit is doubled, starting with the digit in second place: 378282246310005 becomes…

Although online payment options such as Pay Pal have become extremely popular in the last couple of years, the majority of online stores still use some sort of merchant system to accept credit card payments from their Websites.

Before you actually encrypt your customer’s credit card numbers to a database or forward them to a merchant server, it’s a good idea to implement your own credit card validation routine.