Credit Card Verification

Verify a Credit Card for free by cross referencing it against the Luhn formula. This formula does not check with the major Credit Card companies for validity, it merely checks the Credit Card number algorithm to make sure it is a valid number for the four major Credit Cards accepted worldwide. Please use a license key of '0' if consuming via Web Service. The Luhn formula can also be used to identify the type of card by the # entered.

Developer/Tester Information
WSDL Testing URL

Pricing
FREE forever. Use the CDYNE Credit Card Verification Web Service or the raw code used to program this Web Service.

Download Credit Card Verification Web Service code examples
ASP .NET VB CFM FLASH JSP PHP

Open Source
Below you can find the C# or VB version of the Credit Card Verification Web Service code using the Luhn Formula.

Luhn Definition
The Luhn algorithm or Luhn formula, also known as the "modulus 10" or "mod 10" algorithm, was developed in the 1960s as a method of validating identification numbers. It is a simple checksum formula used to validate a variety of account numbers, such as credit card numbers and Canadian Social Insurance Numbers. Much of its notoriety comes from credit card companies' adoption of it shortly after its creation in the late 1960s by IBM scientist Hans Peter Luhn (1896–1964).

Explanation of the Luhn's algorithm can be found here.

C# Source Code
The original code below (at the bottom) is INCORRECT... this one is used and tested and reflects the C# above more

Dim theNumber As String = Misc.Strings.MakeAllNumeric(accountNumber) 'i.e. 1234-5678-9012-3452 = 1234567890123452 If String.IsNullOrEmpty(theNumber) Then Return False

'Process digits from right to left Dim sum As Int32 = 0 Dim theDigit As Int32 = 0 For i As Int32 = theNumber.Length - 1 To 0 Step -1

theDigit = Convert.ToInt32(theNumber.Substring(i, 1)) 'GET THE DIGIT (starting from the right)

'USE THE EVEN DIGIT on EVEN LEN CARDS; ODD DIGIT on ODD LENGTH CARDS 'EXAMPLE: "even" len card number ending in xxx51908 '          8 + (0*2) + 9 + (1*2)             'EXAMPLE: "odd" len card number 49927398716 '          6 + (1*2) + 7 + (8*2) + 9 + (3*2)... you get the point... but see next line '          6 + 2     + 7 + (1+6) + 9 + 6.... see the "break apart" the 16 = 1 + 6 If ((i Mod 2) = (theNumber.Length Mod 2)) Then 'the product = (theDigit * 2) 'example: 6*2 = 12 or 9*2 = 18 or 7*2 = 14 ' OVER 9 THEN Break the digits up and add them together (eg. 18 becomes 1 + 8, 14 becomes 1 + 4) ' UNDER 10 THEN JUST ADD IT     If (theDigit * 2) >= 10 Then sum += ((theDigit * 2) \ 10) + ((theDigit * 2) - 10) Else sum += (theDigit * 2) End If  Else sum += theDigit End If Next

'RETURN 10's COMPLIMENT Return ((sum Mod 10) = 0)


 * ORGINAL CODE  ******

PHP Example for Web Service
class CCVerify { private $CardNumber; public $response; public function __construct($CardNumber) { $this->CardNumber = $CardNumber; $this->getResponse; }	public function getResponse{ $url = "https://ws.cdyne.com/creditcardverify/luhnchecker.asmx"; $url .= "/CheckCC?CardNumber=". $this->CardNumber; $this->response = simplexml_load_file($url) or die("ERROR"); } } $CardNumber = "123412341243124"; $results = new CCVerify( $CardNumber ); var_dump($results);