Generation

  1. Prerequisite
  2. Synchronous
  3. Asynchronous

1. Prerequisite

To generate an IBAN code you first need to know
  • to which country the code belongs
  • what the current bank ident is
  • what the current account number is

Supported countries are in the ECountry-Enumeration in the AS.IBAN.Model-Namespace. If you have the country code you simply could parse this code to ECountry-Enumeration:

private ECountry MappToIbanCountry(string country_code)
{
    return (ECountry)Enum.Parse(typeof(ECountry), country_code);
}

2. Synchronous

To generate an IBAN code in synchronous way, you could do something like this:

[...]
//    Include IBAN-Api AVENTUM SOLUTIONS GmbH
using AS.IBAN;
using AS.IBAN.Model;
using AS.IBAN.Helper;
[...]
{
[...]
        private string GenerateGermanIban(string bankIdent, string accountNumber)
        {
            IbanGenerator generator = new IbanGenerator();
            string iban = string.Empty;
            string bic = string.Empty;

            try
            {
                var result = generator.GenerateIban(ECountry.DE, bankIdent, accountNumber);

                iban = result.IBAN.IBAN;
                bic = result.BIC.Bic;
            }
            catch (IbanException ex)
            {
                //  do some error handling
            }

            return iban;
        }
[...]
}

3. Asynchronous

Following the async-await pattern you can also generate an IBAN code in asynchronous way. You could do something like this:

[...]
//    Include IBAN-Api AVENTUM SOLUTIONS GmbH
using AS.IBAN;
using AS.IBAN.Model;
using AS.IBAN.Helper;
[...]
{
[...]
        private async Task<string> GenerateGermanIban(string bankIdent, string accountNumber)
        {
            IbanGenerator generator = new IbanGenerator();
            string iban = string.Empty;
            string bic = string.Empty;

            try
            {
                var result = await generator.GenerateIbanAsync(ECountry.DE, bankIdent, accountNumber);

                iban = result.IBAN.IBAN;
                bic = result.BIC.Bic;
            }
            catch (IbanException ex)
            {
                //  do some error handling
            }

            return iban;
        }
[...]
}




Last edited Nov 22, 2013 at 4:34 PM by AventumSolutions, version 9