readefries/IBAN-Helper

Not working for several NO Ibans

Closed this issue · 9 comments

Not working for:
NO93 7058 0671 290
NO93 5005 0669 316

You can check that those are valid IBANs at http://www.xe.com/ibancalculator/

Hi @szpako1, i'll try to take a look at it in the coming week. I don't think I have time during the Easter weekend though :D

Hey @szpako1 I tried both provided IBAN, but the checksum for both of them seems to be incorrect.

The checksum of the first should be 75 and the second 69.
See IBAN Calculator

The link you supplied, only extracts the IBAN and shows of which parts it consists. It doesn't states it's valid at all.

@readefries those IBANs comes from real invoices. I only added to them NO93.

Ah, ok. The 93 is the checksum, which is not valid for both accounts.
The correct IBANs should be :

  • NO75 7058 0671 290
  • NO69 5005 0669 316

@readefries ok, so how can I check IBAN when I know only account number (BBAN i suppose), I have tried with that:

let account = "70580671290"
  let structure = RFIBANHelper.ibanStructure("NO")
  let checksum = RFIBANHelper.checkSumForIban(account, structure:structure)
  let iban = "NO\(checksum)\(account)" // NO2070580671290
  RFIBANHelper.isValidIBAN(iban) // invalidChecksum

@readefries ok, succeed

let account = "70580671290"
let structure = RFIBANHelper.ibanStructure("NO")
let checksum = RFIBANHelper.checkSumForIban("NO00" + account, structure:structure)
let iban = "NO\(checksum)\(account)"

@readefries damm it, it always returns valid even for "11111111111", do you know how could I validate account number (BBAN)?

Creating an IBAN from only an BBAN, isn't that straight forward. As not all countries use the same method to do so, and I can't find a list of how countries do this. Some countries use a part of the BIC as part of the IBAN, as we do in the Netherlands. But in Norway, they don't use that.

I added a playground, with some examples. Please note, the generation of IBAN's is not reliable, as I have no overview on how these are generated per country.