Checks a credit card number for validity.
The system performs checks on the number range and a checksum calculation to ensure no typographical errors have been entered. It does not check with the bank that the card is live, has available credit and has not expired.
Language:
<!-- Import the Integr8 Ajax API -->
<!-- NOTE: Get your own API key to use in the following script tag from: -->
<!-- http://www.data-8.co.uk/integr8/Admin/Ajax.aspx -->
<script src="http://webservices.data-8.co.uk/Javascript/Loader.ashx?key=your-api-key" type="text/javascript">
</script>
<script type="text/javascript">
function loadIntegr8() {
// Load the CreditCardValidation Integr8 service
data8.load('CreditCardValidation');
}
function IsValid(request) {
/// <param name="request">data8.creditcardvalidationrequest. Set up the CreditCardType, CreditCardNumber properties before calling this method.</param>
var creditcardvalidation = new data8.creditcardvalidation();
creditcardvalidation.isvalid(
request,
null,
showIsValidResult
);
}
function showIsValidResult(result) {
// Check that the call succeeded, and show the error message if there was a problem.
if (!result.Status.Success) {
alert('Error: ' + result.Status.ErrorMessage);
}
else {
// TODO: Process method results here.
// Results can be extracted from the following fields:
// result.CreditCardType
// Contains a type to indicate what type of Credit Card the card was validated to
// result.Valid
// Contains a status code indicating if the incoming credit card number and credit card type could be validated.
}
}
loadIntegr8();
</script>
// NOTE: A reference to the web service must be added in Visual Studio with the URL
// http://webservices.data-8.co.uk/CreditCardValidation.asmx
private void IsValid(CreditCardValidationRequest request)
{
// Invoke the web service method.
CreditCardValidation proxy = new CreditCardValidation();
CreditCardValidationResponse results = proxy.IsValid("username", "password", request, null);
// Check that the call succeeded, and show the error message if there was a problem.
if ((results.Status.Success == false))
{
MessageBox.Show(("Error: " + results.Status.ErrorMessage));
}
else
{
// TODO: Process method results here.
// Results can be extracted from the following fields:
// result.CreditCardType
// Contains a type to indicate what type of Credit Card the card was validated to
// result.Valid
// Contains a status code indicating if the incoming credit card number and credit card type could be validated.
}
}
'NOTE: A reference to the web service must be added in Visual Studio with the URL
'http://webservices.data-8.co.uk/CreditCardValidation.asmx
Private Sub IsValid(ByVal request As CreditCardValidationRequest)
'Invoke the web service method.
Dim proxy As CreditCardValidation = New CreditCardValidation()
Dim results As CreditCardValidationResponse = proxy.IsValid("username", "password", request, Nothing)
'Check that the call succeeded, and show the error message if there was a problem.
If (results.Status.Success Is false) Then
MessageBox.Show(("Error: " + results.Status.ErrorMessage))
Else
'TODO: Process method results here.
'Results can be extracted from the following fields:
'result.CreditCardType
' Contains a type to indicate what type of Credit Card the card was validated to
'result.Valid
' Contains a status code indicating if the incoming credit card number and credit card type could be validated.
End If
End Sub
Public Sub IsValid(type As String, creditcardnumber As String)
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "http://webservices.data-8.co.uk/recordset.ashx?service=CreditCardValidation&method=IsValidSimple" &
"&username=your-username" &
"&password=your-password" &
"&type=" & type &
"&creditcardnumber=" & creditcardnumber
If rs.MoveFirst Then
If rs.Fields(0).Name = "Success" And rs.Fields(0).Value = false Then
MsgBox "Error: " & rs.Fields(1)
Else
'TODO: Process method results here.
'All the results are available in the first row in the recordset.
'Results can be extracted from the following fields:
'CreditCardType
' Contains a type to indicate what type of Credit Card the card was validated to
'Valid
' Contains a status code indicating if the incoming credit card number and credit card type could be validated.
End If
End If
End Sub
// NOTE: The php_soap.dll extension must be enabled in the php.ini file.
function IsValid($request)
{
$params = array(
"username" => "your-username",
"password" => "your-password",
"request" => $request,
"options" => $options
);
$client = new SoapClient("http://webservices.data-8.co.uk/CreditCardValidation.asmx?WSDL");
$result = $client->IsValid($params);
if ($result->IsValidResult->Status->Success == 0)
{
echo "Error: " . $result->IsValidResult->Status->ErrorMessage;
}
else
{
// TODO: Process method results here.
// Results can be extracted from the following fields:
// $result->IsValidResult->CreditCardType
// Contains a type to indicate what type of Credit Card the card was validated to
// $result->IsValidResult->Valid
// Contains a status code indicating if the incoming credit card number and credit card type could be validated.
}
}