Exemple #1
0
        public static BankReference CreateReference(BankReference reference)
        {
            //There is currently no format check and error handling,
            //currently always created from other reference that is assumed to be valid!
            string referenceIdentifier  = "RF";
            string alphanumericSequence = reference.Reference + referenceIdentifier + "00";
            string digitSequence        = String.Empty;

            CharacterConverter.Convert(alphanumericSequence, out digitSequence);
            string checkDigits       = Modulus97.GetCheckDigits(digitSequence);
            string referenceSequence = referenceIdentifier + checkDigits + reference.Reference;

            return(new InternationalReference(referenceSequence));
        }
 private static bool isValid(string iban)
 {
     if (hasValidFormat(iban))
     {
         string ibanCountryCode = iban.Substring(0, 2);
         string ibanCheckDigits = iban.Substring(2, 2);
         string ibanBban        = iban.Substring(4);
         string checkSequence   = ibanBban + ibanCountryCode + ibanCheckDigits;
         string digitSequence   = String.Empty;
         if (CharacterConverter.Convert(checkSequence, out digitSequence))
         {
             //Console.WriteLine("\nCheck string: {0}", checkSequence);
             //Console.WriteLine("\nValidation string: {0}", digitSequence);
             return(Modulus97.ValidateCheckDigits(digitSequence));
         }
     }
     return(false);
 }
Exemple #3
0
 private static bool isValid(string reference)
 {
     if (hasValidFormat(reference))
     {
         string referenceIdentifier = reference.Substring(0, 2);
         string checkDigits         = reference.Substring(2, 2);
         string referenceSequence   = reference.Substring(4);
         string checkSequence       = referenceSequence + referenceIdentifier + checkDigits;
         string digitSequence       = String.Empty;
         //International reference number may contain both upper and lower case characters
         //From validation point of view case is insignificant, digit values are the same for upper and lower case
         //Conversion is done in upper case
         if (CharacterConverter.Convert(checkSequence.ToUpper(), out digitSequence))
         {
             //Console.WriteLine("\nCheck string: {0}", checkSequence);
             //Console.WriteLine("\nValidation string: {0}", digitSequence);
             return(Modulus97.ValidateCheckDigits(digitSequence));
         }
     }
     return(false);
 }