Validates a Credit Card Number. For a credit card function that also checks start and expirery dates and also the issue number, see validateCreditCardEx
Syntax:
validateCreditCard (string keycode, string cardnumber)
Notes and usage guidelines
validateCreditCard is a simple check that the card number is valid.
A valid credit card number is defined as a number that passes the credit card mathematical algorithm check. On its own validateCreditCard does not check that the card is a real credit card or that the card has been lost, stolen or involved in fraud.
Returned
data
An object creditcard containing the following fields:
String
‘Invalid’ if the card number is not valid.
Name
Description
cardNumber
The card number of the card to
be validated.
validity
String ‘Valid’ if the card number is valid.
issuer
The card issuer - the
financial institution that provided the card to be validated.
cardScheme
The scheme (eg Visa,
Mastercard) that the card being validated belongs to.
productType
The type of card as determined
by the issuer.
usage
The prescribed usage of the
card being validated
switchIssue
String
‘TRUE’ if the card has an issue number, otherwise null
switchIssueLength
If the card being validated
includes an issue number then the number of digits in the issue number is
in this field.
switchStandardCard
reserved
panLength
The length
of the PAN
binType
notes
Special
notes and instructions that accompany some cards.
majorIndustryIndicator
A description of the Industry
category of the card issuer.
StsNotCorD
reserved
StsNotList
reserved
StsBadCard
reserved
errorCode
If an
error occurs during processing the error number will be here. See
the error section for more details.
errorText
If an error occurs
during processing the error textually description will be here. See the
error section for more details.
Supported Versions
Validate Web Service Version 1.x
Errors
1234 | Card Number is null |
1235 | Card Number is not numeric |
1236 | Card Number is not a valid credit card number |
1237 | Invalid Card Number Length |
1238 | Card Number error |
Example
Code
Note: We obviously cannot print a real credit card number in this guide and so we use a test number from Visa '4111 1111 1111 1111'. This is technically a correct credit card number and so validity will be returned as valid. However all other information such as Issuer, card scheme, etc will be returned as not found.
c#
The following sample show how to use the validateCreditCard function using
c#.
As with all
examples, please see the section Adding a reference to
the Validate Web Service .
c# Example 1
string
cardNumber = "4111 1111 1111
1111"; // a valid
Visa test number
validate.validate wsObject = new validate.validate();
validate.creditcard cardObject =
wsObject.validateCreditCard(keycode,
cardNumber);< /FONT
>
c# Example 2 using
validate. }
using System.Collections.Generic;
using
System.Text;
namespace
validateCreditCard
{
class Program
{
static void Main(string[]
args)
{
string keycode =
"qwerty";
string
cardNumber = "4111 1111 1111
1111"; // a valid
Visa test number
validate.creditcard cardObject = wsObject.validateCreditCard(keycode,
cardNumber);
Console.WriteLine(cardObject.validity);
Console.WriteLine(cardObject.errorCode);
Console.WriteLine(cardObject.errorText);
Console.ReadLine();
}
}
Visual Basic .net
The following sample show how to use the validateCreditCard function
using vb.net.
As with all examples, please see
the section Adding a reference to the Validate Web
Service .
Visual Basic.net Example 1
Dim wsobject As New
validate.validate()
Dim cardObject As validate.creditcard
cardObject = wsobject.validateCreditCard("qwerty","4111 1111 1111
1111")
Visual Basic.net Example 2 Module Module1Sub Main() ' define the keycode, etc Dim keycode As String = "qwerty" Dim cardNumber As String = "4111 1111 1111 1111" ' Create a web service object Dim wsobject As New validate.validate() ' create a creditcard object for the returning data Dim cardObject As validate.creditcard ' Call the web service function cardObject = wsobject.validateCreditCard(keycode, cardNumber) ' display the result Console.WriteLine(cardObject.validity) Console.WriteLine(cardObject.errorCode) Console.WriteLine(cardObject.errorText) Console.ReadLine() End Sub End Module |
Java
The following sample show how to use the validateCreditCard function
using Java.
Java Example 1
public class Main { public static void main(String[] args) {
validate.Validate service = new
validate.Validate();
java.lang.String keycode = "qwerty"
;
validate.Creditcard result = port.validateCreditCard(keycode,
cardnumber); |
XML Messages
Below is a typical XML message request
<?
xml version="1.0" encoding="utf-8"?>Below is a typical XML message response
<?
xml version="1.0" encoding="utf-8"?>Below is an example of using validateCreditCard via a URL encoded GET request
serviceUrl.asmx/ccard2.aspx?keycode=qwerty&cardnumber=4111111111111111
![]() |
©Copyright 2023 Paygate Solutions Limited |