|
Call ValidateCardDetails serviceTo validate cards, you need to call ValidateCardDetails, supplying the PAN, CVV, and expiry date. For some cards, such as Switch cards, you also need to supply the issue number and valid from date. Get validation responseTo find out whether the card passed validation, you need to retrieve the validation response. Are there any errors?If the card failed validation, card conditions are returned. Therefore to see if there were validation errors, you need to check whether CardCondition contains any information. ![]() if (response.CardValidationResponse.CardConditions != null) If there are errors you need to extract the codes and any returned reasons to determine why the card details failed validation. Not every code has an associated reason.
![]() foreach (var CardCondition in response.CardValidationResponse.CardCondition) Console.WriteLine("Card validation failed with code: (0) Severity: (1) Reason: (2)") CardCondition.Code, CardCondition.Severity, CardCondition.Reason); |
If the validation was successful or the BIN exists, details about the card are returned. Your business requirements will determine which of these details you need.
if (response.CardValidationResponse.CardType.HasValue)
Console.WriteLine("Card type => {0}", Enum.GetName(typeof(TypeOfCard), response.CardValidationResponse.CardType.Value));
if (response.CardValidationResponse.SubType.HasValue)
Console.WriteLine("Card sub-type => {0}", Enum.GetName(typeof(SubTypeOfCard), response.CardValidationResponse.SubType.Value));
if (!string.IsNullOrEmpty(response.CardValidationResponse.IssuerName))
Console.WriteLine("Card issuer => {0}", response.CardValidationResponse.IssuerName);
if (!string.IsNullOrEmpty(response.CardValidationResponse.SchemeName))
Console.WriteLine("Card scheme => {0}", response.CardValidationResponse.SchemeName);
Your application should interpret the validation results and display messages suitable for your users. For example, when code 4 is returned with no reason code, your application could display "The Card Number failed validation".