r/PHPhelp • u/nickdavies07 • May 26 '19
An API for IBAN conversion?
Is there a free API that anyone knows of to allow conversion of bank sort codes and account numbers into IBANs?
IBAN have a paid one, but pricing is expensive.
1
u/the_alias_of_andrea May 26 '19
What do you actually need this for? If you're targeting users in the Single Euro Payment Area (all EU and EEA countries), they can easily find out their IBANs from their banks, and Eurozone users don't have other bank account sort codes or numbers. If you're targeting users outside SEPA, well, most countries in the world do not use the IBAN, and an IBAN on its own isn't sufficient to send a payment outside SEPA…
1
u/nickdavies07 May 26 '19
It’s actually only for a bit of automation in our business, we primarily deal with payments in the United Kingdom, Malaysia and Egypt. We have a form for finance to enter supplier information; they provide various information including the bank sort and account number. We encourage them to enter the IBAN as well as it becomes more recognised and is easier for sending payments. So really we’d like something that helps those users out by converting it for them so they haven’t got to deal with finding this information.
1
u/the_alias_of_andrea May 26 '19
I see, that sounds reasonable I guess. IBANs have the significant advantage that they contain a checksum and can be machine-validated offline, so it's difficult to input them wrong.
1
u/judgej2 May 26 '19 edited May 26 '19
The eISCD list is updated weekly, and being monopolised, you will find it hard to get a cheap list anywhere. However, the list contains frequent changes to services and branch addresses and names, so if that is not important to you, then the mapping of sort codes to bank codes is fairly stable (though think about banks splitting up, buying up other banks - that has happened a lot lately).
The format of the IBAN is simple enough, with a built-in checksum (it is the BBAN + country code + check digits), but what the eISCD list does is:
Checks the sort code is valid, i.e. registered for use.
Looks up the bank code for the sort code, e.g. 560036 = NWBK.
On top of that, you can validate that the account number is probably a valid number for the sort code (though may still be for an account that does not exist or has been closed). There are plenty of libraries for that, the "modulus checks" and the up-to-date list is free from Vocalink.
The eISCD data is distributed via an hierarchy of agents. So to get the full list for any use, weekly, you will be paying enormous sums. But those top-tier users then use the data to provide services to their clients, and so on. Each level introduces more restrictions on the data (e.g. the rate of requests that can be made) but will get cheaper as a result of the shared costs. Vocalink charge just under two grand pa for access, so there will be cheaper suppliers for smaller companies. If you want the full set source data, then be prepared to take out a small mortgage ;-) I suspect you won't need that though.
1
u/the_alias_of_andrea May 26 '19
But that's only for the UK?
1
u/judgej2 May 26 '19
Yes. Sorry, it didn't consider other countries. It does get a lot more complicated when you put all the different standards around the world together. An IBAN for the UK would need to use all those APIs, so I guess there would be equivalent for every other country. I imagine it would be expensive to run such a service, which is probably why you are finding it costly.
1
u/QBaseX Sep 21 '24
Sort codes are specific to the UK, Ireland, the Isle of Man, Jersey, and Guernsey. No other counties use them (though other countries do have analogues, such as Australia's BSB codes, which are also six digits).
For the UK, you can probably find a lookup table to get the BIC from the sort code. For the BBAN, you need the first four letters of the BIC, then the six digits of the sort code, then the eight digits of the account number. Then add GB on the end, do the calculation to generate the check digits, take GB back off the end, and then put GB plus the check digits on the beginning. That's it.
For Ireland, it's the same, but with IE.
The islands are difficult, as some banks there participate in the UK banking system instead of the local one, so an Isle of Man IBAN may well start with GB instead of IM. You may be able to divine that from the BIC, which should include the country code.
4
u/[deleted] May 26 '19
Pay the money. That'll get you an up-to-date list, and someone to complain to if you find a mistake. In this instance, it's worth it, and you need to budget for it as part of the project.