Re: Re: Credit card checks?
| From: | Mark McCulligh | Date: | Wed, 24 Jul 2002 01:06:28 +0000 |
| Subject: | Re: Re: Credit card checks? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-109180@lists.php.net to get a copy of this message | ||
There is a credit card validating class on phpclasses.org under e-commerce.
"Martin Towell" <martin.towell@world.net> wrote in message
news:6416776FCC55D511BC4E0090274EFEF5034CFBAF@EXCHANGE...
> Try this:
>
> function do_mod_10($num)
> {
> // The Luhn formula works right to left, so reverse the number.
> $num = strrev($num);
> $total = 0;
> for ($i = 0, $j = 1; $i < strlen($num); $i++, $j=3-$j)
> {
> $digit = $num[$i] * $j;
> if ($digit > 9) $digit -= 9;
> $total += $digit;
> }
>
> return ($total % 10 == 0);
> }
>
> -----Original Message-----
> From: Mark McCulligh [mailto:mmcculli@sykescanada.com]
> Sent: Wednesday, July 24, 2002 10:47 AM
> To: php-general@lists.php.net
> Subject: [PHP] Re: Credit card checks?
>
>
> You could use an algorithms called mod10. Both Visa, MasterCard and I
think
> most other credit cards use the mod10 algorithm. A credit card must pass
a
> mod10 test to be a valid number(Like a Regular Expression test). It won't
> tell you if the number exist, but it will tell you if it could exist. I
> also know the mod10 is used for Canadian Social Security numbers (SIN).
>
> Unfortunately I have never seen a PHP function for it, I only used mod10
in
> a language called Uniface by Compuware. I know there is another name for
> it also, but I can't remember it right now.
>
> It is a great test, someone just typing in numbers at random will have a
> terrible time guessing a number right. I have never seen someone do it
let.
> Then you can use the first character of the number to test the card type.
>
> I will see if I can locate the algorithm and email it too you.
>
>
> Mark
>
> "Jas" <jlgerfen@hotmail.com> wrote in message
> news:20020723181239.25134.qmail@pb1.pair.com...
> > Just wondering if anyone has come across the need to develop a class to
> test
> > a string of numbers based on a credit card type. If you have where
would
> I
> > be able to get information on what string of numbers is consistent with
> each
> > of the different credit cards? Any help would be appreciated!
> > Jas
> >
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php