ibandit 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,70 @@
1
+ Name of country Country code as defined in ISO 3166 Domestic account number example BBAN BBAN structure BBAN length Bank identifier position within the BBAN Bank identifier length Bank identifier example BBAN example IBAN IBAN structure IBAN length IBAN electronic format example IBAN print format example SEPA Country Contact details
2
+ Albania AL 0000000235698741 0 8!n16!c 24 "Bank Identifier 1-3, Branch Identifier:4-7, Check Digit 8" 8!n 212-1100-9 212110090000000235698741 0 AL2!n8!n16!c 28 AL47212110090000000235698741 AL47 2121 1009 0000 0002 3569 8741 No "Miho Valer , Deputy Director, Payment Systems Department, BANK OF ALBANIA, Kompleksi Halili, Rruga e Dibres, 1000 TIRANA, ALBANIA, Tel: 355 4 2419301/2/3 ext 3061, Fax: 355 4 2419408 , Email: vmiho@bankofalbania.org"
3
+ Andorra AD 2030200359100100 0 4!n4!n12!c 20 "Positions 1-4, Branch identifier: positions 5-8" "4!n, Branch identifier length: 4!n" "0001, Branch identifier example: 2030" 00012030200359100100 0 AD2!n4!n4!n12!c 24 AD1200012030200359100100 AD12 0001 2030 2003 5910 0100 No "Associació de Bancs Andorrans (ABA), C/ Ciutat de Consuegra, 16, Edifici l’Illa, esc. A, 2n pis, AD500 Andorra la Vella, Principat d’Andorra, Tel: 376 80 71 10, Fax: 376 86 68 47, Email: aba@aba.ad"
4
+ Austria AT BLZ 19043 Kto 234573201 0 5!n11!n 16 Positions 1-5 5!n 19043 1904300234573201 0 AT2!n5!n11!n 20 AT611904300234573201 AT61 1904 3002 3457 3201 Yes "Mr. Hendrik Muus, STUZZA, Stiftgasse 15/8, A-1070 WIEN, Tel: 43 1 505 32 80 / 73, Fax: 43 1 505 32 80 / 77, Email: hendrik.muus@stuzza.at Website http://www.stuzza.at"
5
+ Republic of Azerbaijan AZ NABZ00000000137010001944 0 4!a20!c 24 Positions 1-4 4!a NABZ NABZ00000000137010001944 0 AZ2!n4!a20!c 28 AZ21NABZ00000000137010001944 AZ21 NABZ 0000 0000 1370 1000 1944 "Central Bank of the Republic of Azerbaijan – Head Office, 32, R. Behbudov, AZ 1014, BAKU, Republic of Azerbaijan, Mr. Gurbanli Vahid, Deputy of Director, Payment systems and settlements, Telephone: +994 12 4931122 (ext.480), Fax: +994 12 493 66 15, e-mail: vahid_gurbanli@cbar.az, Mr. Rasulov Orkhan, Chief system administrator, Payment systems and settlements, Telephone: +994 12 4931122 (ext.481), Fax: +994 12 498 75 73, e-mail: orkhan_rasulov@cbar.az "
6
+ Bahrain (Kingdom of) BH 00001299123456 0 4!a14!c 18 Positions 1-4 4!n BMAG BMAG00001299123456 0 BH2!n4!a14!c 22 BH67BMAG00001299123456 BH67 BMAG 0000 1299 1234 56 No "Mr. AL-FADHEL Mohammed A., Head- Payment and Settlement Banking Services Directorate, Telephone: +973 17547758, Fax: +973 17532050, e-mail: malfadhel@ccb.gov.bh "
7
+ Belgium BE 539-0075470-34 0 3!n7!n2!n 12 Positions 1-3 3!n 539 539007547034 0 BE2!n3!n7!n2!n 16 BE68539007547034 BE68 5390 0754 7034 Yes "Mr. P. WYNANT, Belgian Bankers’ Association - Febelfin, Email: ori@febelfin.be"
8
+ Bosnia and Herzegovina BA 199-044-00012002-79 0 3!n3!n8!n2!n 16 "Positions 1-3, Branch identifier positions: 4-6 " "3!n, Branch identifier length: 3!n" "199, Branch identifier example: 044" 1990440001200279 0 BA2!n3!n3!n8!n2!n 20 BA391290079401028494 BA39 1290 0794 0102 8494 No "Mrs. Anja MARGETIC, Payment Systems Division, Centralna banka Bosne I Hercegovine, Marsala Tita 25, 71000 Sarajevo, Bosnia and Herzegovina, Tel: 387 33 286 485, Fax: 387 33 286 455, Email: amargetic@cbbh.ba"
9
+ Brazil BR 0009795493C1 0 8!n5!n10!n1!a1!c 25 Positions 1-8; branch identifier 9-13 8 00360305 00360305000010009795493P1 0 BR2!n8!n5!n10!n1!a1!c 29 BR9700360305000010009795493P1 - BR1800000000141455123924100C2 BR97 0036 0305 0000 1000 9795 493P 1 - BR18 0000 0000 1414 5512 3924 100C 2 No "BANCO CENTRAL DO BRASIL, SBS Quadra 3 Bloco B, 71.070-900 Brasília, iban@bcb.gov.br "
10
+ Bulgaria BG BG80 BNBG 9661 1020 3456 78 0 4!a4!n2!n8!c 18 "Positions 1-4, Branch identifier positions: 5-8 " "4!a, Branch identifier length: 4!n" "BNBG, Branch identifier example: 9661 " BNBG96611020345678 0 BG2!n4!a4!n2!n8!c 22 BG80BNBG96611020345678 BG80 BNBG 9661 1020 3456 78 Yes "Ms Svetla Nickolova, Senior Expert - Payment System Division, Banking Policy Directorate, Bulgarian National Bank, Tel: 359 2 9145 773, Fax: 359 2 980 1012, Email:Nickolova.S@bnbank.org, Website://www.bnb.bg"
11
+ Costa Rica CR 1026284066 0 3!n14!n 17 "Positions 1-3, Branch is not available " 3!n 152 15202001026284066 0 CR2!n3!n14!n 21 CR15202001026284066 CR05 1520 2001 0262 8406 6 No "Nidia Quintero, Payment System Officer, Sistema de Pagos, Tel: 506 2243-3648, Fax: 506 2243-4565, Email: quinteromn@bccr.fi.cr, Mr. Francisco Carvajal, Director, Sistema de Pagos, Tel: 506 2243-3655, Fax: 506 2243-4565, Email: carvajalcf@bccr.fi.cr, Banco Central de Costa Rica, Avenida Central y 1a. Calles 2y4, 10058-1000 San José, Costa Rica"
12
+ Croatia HR 1001005-1863000160 0 7!n10!n 17 Positions 1-7 7!n 1001005 10010051863000160 0 HR2!n7!n10!n 21 HR1210010051863000160 HR12 1001 0051 8630 0016 0 No "Mr. Ivan BILUS, Tel: +385 1 45 64 627, Fax: +385 1 45 50 588, Email: ivan.bilus@hnb.hr, Web: hhtp://www.hnb.hr"
13
+ Cyprus CY 1200527600 0 3!n5!n16!c 24 "Positions 1-3, Branch identifier positions: 4-8 " "3!n, Branch identifier length: 5!n" "002, Branch identifier example: 00128" 002001280000001200527600 0 CY2!n3!n5!n16!c 28 CY17002001280000001200527600 CY17 0020 0128 0000 0012 0052 7600 Yes "Mrs. Christa Piki, Payment systems and Accounting Services Department, Central Bank of Cyprus, 80 Kennedy Avenue, P.O. Box 25529, CY-1395 Nicosia, Tel: +357-22714405, Fax: +357-22378505, Email:PaymentSystems@centralbank.gov.cy, http://www.centralbank.gov.cy/nqcontent.cfm?a_id=2820"
14
+ Czech Republic CZ 19-2000145399/0800 0 4!n6!n10!n 20 Positions 1-4 4!n 0800 08000000192000145399 0 CZ2!n4!n6!n10!n 24 CZ6508000000192000145399 CZ9455000000001011038930 CZ65 0800 0000 1920 0014 5399 CZ94 5500 0000 0010 1103 8930 Yes "Mr. Ivan FENCL, Czech National Bank, Na Prikope 28, Praha 1, Tel: +420 224 413 580, Fax: +420 224 413 351, Email: Iban.info@cnb.cz, http://www.cnb.cz/cs/platebni_styk/iban/index.html for Czech language, http://www.cnb.cz/en/payment_systems/iban/index.html for English."
15
+ Denmark DK "0040 0440116243, 6460 0001631634, 6471 0001000206" 0 4!n9!n1!n 14 Positions 1-4 4!n "0040, 6460, 6471" "00400440116243, 64600001631634, 64710001000206" 0 "DK2!n4!n9!n1!n, FO2!n4!n9!n1!n, GL2!n4!n9!n1!n" 18 "DK5000400440116243, FO6264600001631634, GL8964710001000206" "DK50 0040 0440 1162 43, FO62 6460 0001 6316 34, GL89 6471 0001 0002 06" Yes "Mr. Carsten PEDERSEN, Danish Bankers Association, 7 Amaliegade, DK 1256 COPENHAGEN K, Tel: 45 33 70 10 00, Fax: 45 33 93 02 60, Email: cpe@finansraadet.dk"
16
+ Faroe Islands FO "0040 0440116243, 6460 0001631634, 6471 0001000206" 0 4!n9!n1!n 14 Positions 1-4 4!n "0040, 6460, 6471" "00400440116243, 64600001631634, 64710001000206" 0 "DK2!n4!n9!n1!n, FO2!n4!n9!n1!n, GL2!n4!n9!n1!n" 18 "DK5000400440116243, FO6264600001631634, GL8964710001000206" "DK50 0040 0440 1162 43, FO62 6460 0001 6316 34, GL89 6471 0001 0002 06" Yes "Mr. Carsten PEDERSEN, Danish Bankers Association, 7 Amaliegade, DK 1256 COPENHAGEN K, Tel: 45 33 70 10 00, Fax: 45 33 93 02 60, Email: cpe@finansraadet.dk"
17
+ Greenland GL "0040 0440116243, 6460 0001631634, 6471 0001000206" 0 4!n9!n1!n 14 Positions 1-4 4!n "0040, 6460, 6471" "00400440116243, 64600001631634, 64710001000206" 0 "DK2!n4!n9!n1!n, FO2!n4!n9!n1!n, GL2!n4!n9!n1!n" 18 "DK5000400440116243, FO6264600001631634, GL8964710001000206" "DK50 0040 0440 1162 43, FO62 6460 0001 6316 34, GL89 6471 0001 0002 06" Yes "Mr. Carsten PEDERSEN, Danish Bankers Association, 7 Amaliegade, DK 1256 COPENHAGEN K, Tel: 45 33 70 10 00, Fax: 45 33 93 02 60, Email: cpe@finansraadet.dk"
18
+ Dominican Republic DO 1212453611324 0 4!c20!n 24 Positions 1-4 4!a BAGR AGR00000001212453611324 0 DO2!n4!c20!n 28 DO28BAGR00000001212453611324 DO28 BAGR 0000 0001 2124 5361 1324 No
19
+ Estonia EE 221020145685 0 2!n2!n11!n1!n 16 Positions 1-2 2!n - first digit of bank code can not be 0 22 2200221020145685 0 EE2!n2!n2!n11!n1!n 20 EE382200221020145685 EE38 2200 2210 2014 5685 Yes "Mr. Enn Riisalu, Estonian Banking Association, Ahtri 12, 10151 Tallinn, Tel: +372 611 6569, Fax: +372 611 6568, Email: pangaliit@pangaliit.ee, Web: www.pangaliit.ee/eng/Codes"
20
+ Finland FI Not in use 0 Not in use n6!n7!n1!n Position 1-3 indicate the bank or banking group Not in use Not in use Not in use 0 FI2!n6!n7!n1!n 18 FI2112345600000785 or FI5542345670000081 FI21 1234 5600 0007 85 "Yes, Also includes Aland Islands AX" "Mrs. Pirjo Ilola, Finnish Bankers’ Association, PO Box 1009, FIN-00101 HELSINKI, Tel: 358 20 793 4255, Fax: 358 20 793 4202, Email: pirjo.ilola@fkl.fi, Web: www.fkl.fi"
21
+ France FR 20041 01005 0500013M026 06 0 5!n5!n11!c2!n 23 Positions 1-5 5!n 20041 20041010050500013M02606 0 FR2!n5!n5!n11!c2!n 27 FR1420041010050500013M02606 FR14 2004 1010 0505 0001 3M02 606 "Yes, included GP, RE, MQ, GF, PM and YT" "CFONB, 18 rue la Fayette, 75009 PARIS, Telephone:+ 33.1.48.00.50.42 Email: cfonb@fbf.fr"
22
+ Georgia GE 0000000101904917 0 2!a16!n 18 Position 1-2 2!a NB NB0000000101904917 0 GE2!n2!a16!n 22 GE29NB0000000101904917 GE29 NB00 0000 0101 9049 17 No "Mr. SHERMAZANASHVILI Giorgi, National Bank of Georgia, Deputy Head of Payment Systems Department, Payment Systems, Sanapiro str. 2, 0114 Tbilisi, Telephone:+995 32 406 202, Fax:+995 32 406 556, e-mail: gshermazanashvili@nbg.gov.ge, Website: http://www.nbg.gov.ge "
23
+ Germany DE Account number (Kontonummer): 532013000 Bank identifier (Bankleitzahl): 37040044 0 8!n10!n; 18 Positions 1-8 8!n 37040044 370400440532013000 0 DE2!n8!n10!n 22 DE89370400440532013000 DE89 3704 0044 0532 0130 00 Yes "Bundesverband Deutscher Banken, Burgstrasse 28, 10178 BERLIN, Tel: +49 30 1663 2301, Fax: +49 30 1663 2399, Email: iban@bdb.de "
24
+ Gibraltar GI 0000 00007099 453 0 4!a15!c 19 Positions 1-4 4!a NWBK NWBK000000007099453 0 GI2!n4!a15!c: 23 GI75NWBK000000007099453 GI75 NWBK 0000 0000 7099 453 Yes "Mrs Heidi A Bocarisa , Head of Banking & Investments Supervision, Financial Services Commission, PO Box 940, Suite 943 Europort, Gibraltar, Tel: +350 40283, Fax: +350 40282, Email: Hbocarisa@fsc.gi"
25
+ Greece GR 01250000000012300695 0 3!n4!n16!c 23 "Positions 1-3, Branch identifier positions: 4-7 " "3!n, Branch identifier length: 4!n" "011, Branch identifier example: 0012" 01101250000000012300695 0 GR2!n3!n4!n16!c 27 GR1601101250000000012300695 GR16 0110 1250 0000 0001 2300 695 Yes Not available for publication
26
+ Guatemala GT 01020000001210029690 0 4!c20!c 24 Positions 1-4 4!c TRAJ TRAJ01020000001210029690 0 GT2!n4!c20!c 28 GT82TRAJ01020000001210029690 GT82 TRAJ 0102 0000 0012 1002 9690 No Not available for publication
27
+ Hungary HU 11773016-11111018-00000000 0 3!n4!n1!n15!n1!n: 24 "positions 1-3, Branch identifier positions: 4-7 " "3!n, Branch identifier length 4!n" "117, Branch identifier example 7301" 117730161111101800000000 0 HU2!n3!n4!n1!n15!n1!n 28 HU42117730161111101800000000 HU42 1177 3016 1111 1018 0000 0000 Yes "Mr. Tamás Földi, Hungarian Banking Association, H-1368 Budapest, P.O.B 242, Tel: +36 1 483 1913, Fax: +36 1 266 1989, Email: foldi@bankszovetseg.hu Or Mrs. Magdolna Forgács, Hungarian Banking Association, H-1368 Budapest, P.O.B 242, Tel: +36 1 483 1910, "
28
+ Iceland IS 0159-26-007654-551073-0339 0 4!n2!n6!n10!n 22 Positions 1-4 4!n 0159 0159260076545510730339 0 IS2!n4!n2!n6!n10!n 26 IS140159260076545510730339 IS14 0159 2600 7654 5510 7303 39 Yes "Mr. H. H. STEINGRIMSSON, Icelandic Banks Data Centre, Kalkofnsvegur 1, 150 - REYKJAVIK, Tel: 354 569 8877, Fax: 354 562 2678, Email helgihst@rb.is"
29
+ Ireland IE 93-11-52 12345678 0 4!a6!n8!n 18 "Positions 1-4, Branch identifier: positions 5-10 " "4!a, Branch identifier length: 6!n" "AIBK, Branch identifier example: 931152" AIBK93115212345678 0 IE2!n4!a6!n8!n 22 IE29AIBK93115212345678 IE29 AIBK 9311 5212 3456 78 Yes "Mr. M. JAMES, Irish Payment Services Organisation Ltd, 12-13 Cumberland Street, Dun Laoghaire, Co. DUBLIN 2, Tel: 353 1 663 67 40, Fax: 353 1 284 34 09, Email Martin.james@ipso.ie"
30
+ Israel IL 10-800-99999999 0 3!n3!n13!n 19 "Positions 1-3, Branch identifier: positions 4-6" "3!n, Branch identifier length: 3!n" "010, Branch identifier example: 800" 0100800000099999999 0 IL2!n3!n3!n13!n 23 IL620108000000099999999 IL62 0108 0000 0009 9999 999 No "Mrs. Regina Sabov, Payment and Settlement Systems, Bank of Israel, Kaplan Street, Kyriat Ben Gurion, 91007 - Jerusalem, Tel: 972-2-6552733, Fax: 972-2-6669733, Email: regina.sabov@boi.org.il"
31
+ Italy IT X 05428 11101 000000123456 0 1!a5!n5!n12!c 23 "Positions 2-6, Branch identifier positions: 7-11 " "5!n, Branch identifier length: 5!n" "05428, Branch identifier example: 11101" X0542811101000000123456 0 IT2!n1!a5!n5!n12!c 27 IT60X0542811101000000123456 IT60 X054 2811 1010 0000 0123 456 Yes "M. Rita Camporeale, Associazione Bancaria Italiana,Head of Payment Systems and Services Department, Via delle Botteghe Oscure, 46, 00186 ROMA, Tel: +39 06 6767332, Fax: , Email: r.camporeale@abi.it"
32
+ Jordan JO 1310000302 0 4!a4!n18!c 26 1 to 4 4!a CBJO CBJO0010000000000131000302 0 2!a2!n4!a4!n18!c 30 JO94CBJO0010000000000131000302 JO94 CBJO 0010 0000 0000 0131 0003 02 "Mr. Sayeh Rami, Head of Electronic Paying Communication Div, Financial, Tel: +96264630301, Fax: +9624638889, Email: rami.sayeh@cbj.gov.jo, Mr. Alrashdan Nibal, Senior Officer, Financial, Tel: +96264630301, Fax: +9624638889, Email: nibal.alrashdan@cbj.gov.jo, Central Bank of Jordan, King Hussein Street, 11118 Amman – Capital, Jordan"
33
+ Kazakhstan KZ KZ86 125K ZT50 0410 0100 0 3!n13!c 16 Positions 1-3 3!n 125 125KZT5004100100 0 "2!a2!n3!n13!c 1,2 characters – country code (KZ) 3,4 characters – IBAN check digits 5,7 characters – bank identifier 8-20 characters – intrabank account number" KZ86125KZT5004100100 No "Mrs. Alina Imangazina, Expert, Payment Systems Department National Bank of the Republic of Kazakhstan 21, Koktem-3, 050040, Almaty, Tel: 7 727 270 47 20, Fax: 7 727 270 48 14, Email: imangazina@nationalbank.kz"
34
+ Republic of Kosovo XK 1000000000000053 0 4!n10!n2!n 16 "Positions 1-4 (position 1-2: Bank identifier, position 3-4: branch identifier)" 4!n 10000 1000000000000053 0 XK2!n4!n10!n2!n 20 XK051000000000000053 XK05 1000 0000 0000 0053 "Kadrijaj Gjylfidane, Director, Payment System Department, Telephone: +386(0)49 740 027, Email: Gjyfidane.kadrijaj@bqk-kos.org, Rrustolli Lumni, Head of System Operations Division, Payment Systems Department, Telephone: +386(0)49 740 121, Email: lumni.rrustolli@bqk-kos.org"
35
+ Kuwait KW CBKU0000000000001234560101 0 4!a22!c 26 Positions 1-4 4!a CBKU CBKU0000000000001234560101 0 KW2!n4!a22! 30 KW81CBKU0000000000001234560101 KW81 CBKU 0000 0000 0000 1234 5601 01 No "Mrs. Hana Razzouqi, Executive Director, Information Technology, and Banking Operation sector, Central Bank of Kuwait, P.O. Box 526 Safat, 13006 Safat, Tel: +965 22451568, Fax: +965 22443357, Email: hrazzouqi@cbk.gov.kw"
36
+ Latvia LV LV80 BANK 0000 4351 9500 1 0 4!a13!c 17 Positions 1-4 4!a BANK BANK0000435195001 0 LV2!n4!a13!c 21 LV80BANK0000435195001 LV80 BANK 0000 4351 9500 1 Yes "Ms Anda Zalmane, Payment Systems Department, Bank of Latvia, K. Valdemra 2a, Riga, LV-1050, Tel: +371 67022 510, Fax: +371 67022 179, Email: Anda.Zalmane@bank.lv"
37
+ Lebanon LB 01 001 901229114 0 4!n20!c 24 Positions 1-4 4!a 0999 0999 0000 0001 0019 0122 9114 0 LB2!n4!n20!c 28 LB62099900000001001901229114 LB62 0999 0000 0001 0019 0122 9114 No "Ms Nahfawi Ghina, Head of SWIFT Unit, Current Operations Department, BANQUE DU LIBAN, 11-5544 BEIRUT, Tel: +961-1-750000 Ext: 4068, Tel: +961-1-750000 Ext: 4068, Email: gnahfawi@bdl.gov.lb"
38
+ Liechtenstein (Principality of) LI 8810 2324013AA 0 5!n12!c 17 Positions 1-5 5!n 08810 088100002324013AA 0 LI2!n5!n12!c 21 LI21088100002324013AA LI21 0881 0000 2324 013A A Yes "Mr. Gert Zimmermann, Rechtskonsulent, Liechtenstein Bankers Association, P.O. Box 254, FL-9490 Vaduz, Tel: 423 230 13 96, Fax: 423 230 13 24, Email: gert.zimmermann@bankenverband.li"
39
+ Lithuania LT LT12 1000 0111 0100 1000 0 5!n11!n 16 Positions 1-5 5!n 10000 1000011101001000 0 LT2!n5!n11!n 20 LT121000011101001000 LT12 1000 0111 0100 1000 Yes "Ms Virginija Bruziene, Payment Systems Department, Bank of Lithuania, Zirmunu St 151, Vilnius, LT 09128, Email: vbruziene@lb.lt, http://www.lb.lt/funkcijos/litas_En.htm"
40
+ Luxembourg LU LU28 0019 4006 4475 0000 0 3!n13!c 16 Positions 1-3 3!n 001 0019400644750000 0 LU2!n3!n13!c 20 LU280019400644750000 LU28 0019 4006 4475 0000 Yes "Mr. J-P Borsa, ABBL - Association des Banques et Banquiers Luxembourg, Boîte Postale 13, L-2010 Luxembourg, Tel: 352 46 36 601, Fax: 352 46 09 21, Email: borsa@abbl.lu "
41
+ "Macedonia, Former Yugoslav Republic of" MK MK07 300 0000000424 25 0 3!n10!c2!n 15 Positions 1-3 3!n 300 250120000058984 0 MK2!n3!n10!c2!n 19 MK07250120000058984 MK07 2501 2000 0058 984 No "Aco Spasovski, M.Sc.Econ , Secretary, Tel: 389 2 3237 425, Fax: 389 2 3116 210, Email: aco@ic.mchamber.org.mk "
42
+ Malta MT 12345MTLCAST001S 0 4!a5!n18!c 27 "Positions 1-4, Branch identifier positions: 5-9" "4!a, Branch identifier length: 5!n" "MALT, Branch identifier example: 01100" MALT011000012345MTLCAST001S 0 MT2!n4!a5!n18!c 31 MT84MALT011000012345MTLCAST001S MT84 MALT 0110 0001 2345 MTLC AST0 01S Yes "The Secretary General, Malta Bankers’ Association, 48/2 Birkirkara Road, Attard BZN 02, Tel: +356 21 421 210, , Tel: +356 21 421 572, Fax:+356 21 424 580, Email: mcba@waldonet.net.mt "
43
+ Mauritania MR 00020 00101 00001234567 53 0 5!n5!n11!n2!n 23 "Positions 1-5, Branch identifier positions: 6-10" "5!n, Branch identifier length: 5!n" "00020, Branch identifier example: 00101" 00020001010000123456753 0 MR135!n5!n11!n2!n 27 MR1300020001010000123456753 MR13 0002 0001 0100 0012 3456 753 No "Banque Centrale de Mauritanie, Avenue de l’Indépendance,BP 623 NOUAKCHOTT, Mr. Ould Babah Ahmed, Banking Standards Project Manager, IT, Tel : (222)5252206, Fax: (222)525759, Email: babah@bcm.mr "
44
+ Mauritius MU MU17 BOMM 0101 1010 3030 0200 000M UR 0 4!a2!n2!n12!n3!n3!a 26 "Positions 1-6, Branch identifier positions: 7-8" "6!c, Branch identifier length: 2!n " "BOMM01, Branch identifier example 01" BOMM0101101030300200000MUR 0 MU2!n4!a2!n2!n12!n3!n3!a 30 MU17BOMM0101101030300200000MUR MU17 BOMM 0101 1010 3030 0200 000M UR No "Mr. Yandraduth Googoolye , Director Accounting, Budgeting and Payment System Bank of Mauritius, Sir William Newton Street, Port Louis, Tel: +230 202 38 42 , Fax: +230 211 71 03, Email: ygoogool@bom.intnet.mu "
45
+ Moldova MD 00225100013104168 0 2!c18!c 20 Positions 1-2 2!c AG AG000225100013104168 0 MD2!n20!c 24 MD24AG000225100013104168 MD24 AG00 0225 1000 1310 4168 No "National Bank of Moldova, 1 Grigore Vieru Avenue, MD-2005, CHISINAU, Republic of Moldova, Mr. Munteanu Igor, Director of Payments System Department, Payments System Department, Tel: +373 22 227361, Fax: +373 22 220591, e-mail: Igor.Munteanu@bnm.md, Ms Turcan-Munteanu Natalia, Head of Regulation and development of payment system Section, Payments System Department, Tel: +373 22 409265, Fax: +373 22 220591, e-mail: Natalia.Turcan-Munteanu@bnm.md"
46
+ Monaco MC 0011111000h 0 5!n5!n11!c2!n 23 "Positions 1-5, Branch identifier positions: 6-10" "5!n, Branch identifier length: 5!n" "Bank identifier 11222, Branch identifier: 11222 00001" 11222 00001 01234567890 30 0 MC2!n5!n5!n11!c2!n 27 MC58 11222 00001 0123456789030 MC58 11222 00001 0123456789030 Yes "Mr. J. DASTAKIAN, Secrétaire Général, 7, rue du Gabian, MC98000, Principauté de MONACO, Tel: 00.377.97.97.84.97, Fax: 00.377.93.30.32.16, Email: jd.amaf@monaco.mc"
47
+ Montenegro ME 505 0000123456789 51 0 3!n13!n2!n 18 Positions 1-3 3!n 505 505000012345678951 0 ME2!n3!n13!n2!n 22 ME25505000012345678951 ME25 5050 0001 2345 6789 51 No "Mr. Mirko Radonjic, Secretary General, Association of Montenegrin Banks Novaka Miloseva bb, 81000 Podgorica Montenegro, Tel: +381 81 232 028 , Fax: +381 81 232 029, Email: udruzenjebanaka@t-com.me"
48
+ The Netherlands NL 041 71 64 300 0 4!a10!n 14 Positions 1-4 4!a ABNA ABNA0417164300 0 NL2!n4!a10!n 18 NL91ABNA0417164300 NL91 ABNA 0417 1643 00 Yes "Betaalvereniging Nederland, P.O Box 83073, 1080 AB Amsterdam, Tel: 31 20 305 19 00, Fax: 31 20 305 19 12, Email: sepa@betaalvereniging.nl "
49
+ Norway NO 8601 11 17947 0 4!n6!n1!n 11 Positions 1-4 4!n 8601 86011117947 0 NO2!n4!n6!n1!n 15 NO9386011117947 NO93 8601 1117 947 Yes "Atle Fjereide, DnB NOR Bank, p.o.box 7100, 5020 Bergen, Tel: +47 918 95 624, e-mail: atle.fjereide@dnbnor.no"
50
+ Pakistan PK 00260101036360 0 4!a16!c 20 "Positions 1-4, Branch is not available" 4!a SCBL SCBL0000001123456702 0 PK2!n4!a16!c 24 PK36SCBL0000001123456702 PK36 SCBL 0000 0011 2345 6702 No "State Bank of Pakistan 4th Floor, Main Building, I.I. Chundrigar Road. 4th Floor, Main Building, I.I. Chundrigar Road. Mr. Khan Zamir Joint Director Payment Systems Department Tel: +92 21 99221152 Fax: +92 21 99212528 Email: zamir.afzal@sbp.org.pk, Mr. Mazhar Faisal Deputy Director Payment Systems Department Tel: +92 21 32453497 Fax: +92 21 99212528 Email: faisal.mazhar@sbp.org.pk"
51
+ "Palestine, State of" PS 400123456702 0 4!a21!c 25 Positions 1-4 4 PALS PALS000000000400123456702 0 PS2!n4!a21!c 29 PS92PALS000000000400123456702 PS92 PALS 0000 0000 0400 1234 5670 2 "PALESTINE MONETARY AUTHORITY, AL-RAMOUNI, Nablus Street, 452 AL-BIREH, Mr. Awwad Riyad, Deputy Director, Payment Systems department, Tel: +970224415250, Fax: +97022407780, Email: rawwad@pma.ps"
52
+ Poland PL 61 1090 1014 0000 0712 1981 2874 0 8!n16!n 24 Positions 1-8 8!n 10901014 109010140000071219812874 0 PL2!n8!n16n 28 PL61109010140000071219812874 PL61 1090 1014 0000 0712 1981 2874 Yes "Mr. Tomasz JONCZYK, Polish Bank Association, 8, Kruczkowskiego Street, 00 – 380 WARSAW, Tel: 48 22 856 08 59, Fax: 48 22 651 63 93, Email: tomasz.jonczyk@kir.com.pl "
53
+ Portugal PT 0002.0123.12345678901.54 0 4!n4!n11!n2!n 21 Positions 1-4 4!n 0002 000201231234567890154 0 PT2!n4!n4!n11!n2!n 25 PT50000201231234567890154 PT50 0002 0123 1234 5678 9015 4 "Yes, Also includes Azores and Madeira" "SIBS FORWARD PAYMENT SOLUTIONS, Rua Soeiro Pereira Gomes, Lote 1, 1649-031 LISBOA, Tel: 351 217813000, Email: webmaster@sibs.pt"
54
+ Qatar QA QA58DOHB00001234567890ABCDEFG 0 QA2!n4!a21!c 29 Position 1-4 VPVG DOHB00001234567890ABCDEFG 0 QA58DOHB00001234567890ABCDEFG 29 QA58DOHB00001234567890ABCDEFG QA58 DOHB 0000 1234 5678 90AB CDEF G No "Mr Ahen Abdoulhadi, Acting Director of Banking Payments and Settlement, Banking Payments and Settlement System, Tel: +974 44456371, Fax: +974 44430382, Email: ahena@qcb.gov.qa, QATAR CENTRAL BANK, Abdulla Bin Jassim Street, 1234 DOHA
55
+ "
56
+ Romania RO RO49 AAAA 1B31 0075 9384 0000 0 4!a16!c 20 Positions 1-4 4!a AAAA AAAA1B31007593840000 0 RO2!n4!a16!c 24 RO49AAAA1B31007593840000 RO49 AAAA 1B31 0075 9384 0000 Yes "Mrs. Ruxandra AVRAM , National Bank of Romania, Lipscani St.,25th, Sector 3, Bucharest 030031, Tel: 00 4021 307 01 98, Fax: 00 4021 312 62 61 , Email: ruxandra.avram@bnro.ro"
57
+ San Marino SM SM86 U032 2509 8000 0000 0270 100 0 1!a5!n5!n12!c 23 "Bank identifier position: 2-6,Branch identifier position: 7-11" "Bank identifier length: 5!n, Branch identifier length: 5!n" "Bank identifier example: 03225, Branch identifier example: 09800" U0322509800000000270100 0 SM2!n1!a5!n5!n12!c 27 SM86U0322509800000000270100 SM86 U032 2509 8000 0000 0270 100 No "Mr. A. Costa, Head of Payments System Department Banca Centrale della Repubblica di San Marino, Via del Voltone, 120, San Marino 47890, Email: acosta@bcsm.sm"
58
+ Saudi Arabia SA 6080101675519 0 2!n18!c 20 Bank identifier position: 1-2 2 80 80000000608010167519 0 SA2!n2!n18!c 24 SA0380000000608010167519 SA03 8000 0000 6080 1016 7519 No "Mr. Abdulmalik Al Sheikh, Director, Banking technology Department (BTD), SAMA, Head Office, P.O. BOX 2992, Riyadh 11169, Email: a_sheikh@sama.gov.sa, Tel: +9661 466 2502"
59
+ Serbia RS 260-0056010016113-79 0 3!n13!n2!n 18 Positions 1-3 3!n 260 260005601001611379 0 RS2!n3!n13!n2!n 22 RS35260005601001611379 RS35 2600 0560 1001 6113 79 No "Mrs. Snezana Zekovic, National bank of Serbia, Nemanjina 17, 11000 Belgrade, Tel: +381 11 333 8050, Fax: +381 11 333 8088, Email: Snezana.Zekovic@nbs.rs"
60
+ Slovak Republic SK 19-8742637541/1200 0 4!n6!n10!n 20 Positions 1-4 4!n 1200 12000000198742637541 0 SK2!n4!n6!n10!n 24 SK3112000000198742637541 SK31 1200 0000 1987 4263 7541 Yes "Mrs Elena Biskupi?ová, National Bank of Slovakia, Imricha Karvaša 1, 813 25 Bratislava 1, Tel: +421 2 5787 2351, Fax: +421 2 5787 1138, Email: Elena.Biskupicova@nbs.sk "
61
+ Slovenia SI 2633 0001 2039 086 0 5!n8!n2!n 15 "Positions 1-5 (positions 1-2 bank identifier; positions 3-5 branch identifier). In case of payment institutions: positions 1-5 payment institution identifier, where positions 1-2 is always 91" "5!n; (2!n - bank identifier, 3!n - branch identifier) or (5!n - payment institution identifier, starting always with 91)" 26330 "263300012039086. In case of credit institution: 26330; 26 - bank identifier, 100 - branch identifier In case of payment institution:26234; ; payment institution identifier, starts with 26" 0 SI2!n5!n8!n2!n 19 SI56191000000123438 SI56 1910 0000 0123 438 Yes "Mrs. Nina Frkovic, Payment and Settlement ystem Department, Bank of Slovenia, Slovenska 35, SI-1505 LJUBLJANA, Tel: +386 1 4719 744, Fax: +386 1 4719 725, Email: nina.frkovic@bsi.si Website www.bsi.si"
62
+ Spain ES 2100 0418 45 0200051332 0 4!n4!n1!n1!n10!n 20 "Positions 1-4, Branch identifier positions: 5-8" "4!n, Branch identifier length: 4!n" "2100, Branch identifier example: 0418" 21000418450200051332 0 ES2!n4!n4!n1!n1!n10!n 24 ES9121000418450200051332 ES91 2100 0418 4502 0005 1332 "Yes, Also includes Canary Islands, Ceuta and Melilla" "Ms. Pilar Clavería, Asociación Española de Banca Privada (AEB), C/ Velázquez, 64 – 66, 28001 MADRID, Tel: 34 91 789 13 11, Email: pclaveria@aebanca.es"
63
+ Sweden SE 1234 12 3456 1 0 3!n16!n1!n 20 Positions 1-3 3!n 123 5000 0000 0583 9825 7466 0 SE2!n3!n16!n1!n 24 SE4550000000058398257466 SE45 5000 0000 0583 9825 7466 Yes "Mr. Lars RUTBERG, Swedish Bankers’ Association, SE - 103 94STOCKHOLM, Tel:46 8 453 44 50, Tel: 46 8 453 44 00, Fax: 46 8 796 44 15, Email: lars.rutberg@bankforeningen.se "
64
+ Switzerland CH 762 1162-3852.957 0 5!n12!c 17 Positions 1-5 5!n 00762 00762011623852957 0 CH2!n5!n12!c 21 CH9300762011623852957 CH93 0076 2011 6238 5295 7 Yes "Zentrale Koordinationsstelle fuer IBAN/IPI, SIX Interbank Clearing Ltd, Technical Support, Hardturmstrasse 201 CH-8021 ZURICH, Tel: +41 58 399 4420, Fax: +41 58 499 4550 , Email: iban@six-group.com, Website: www.iban.ch"
65
+ Timor-Leste TL 008 00123456789101 57 0 3!n 14!n 2!n 19 "Positions 1 to 3, Positions 1-4: TL38, Positions 5-7: Bank Code, Positions 8-21 : Customer account number, Positions 22-23: National check digit (modulo 97)" 3!n 008 0080012345678910157 0 TL2!n3!n14!n2!n 23 TL380080012345678910157 TL38 0080 0123 4567 8910 157 "M. Brites Sara Lobo- Deputy Governor, Depatment of Payments and Banking, Telephone: +670 3313 718, Fax: +670 3313 713, e-mail: sara.brites@bancocentral.tl, Mr. Alkatiri Nur-Aini - Deputy Governor of Financial Supervision, Telephone: +670 3313 318, Fax: +670 3313 316, e-mail: nur.alkatiri@bancocentral.tl"
66
+ Tunisia TN 10 006 0351835984788 31 0 2!n3!n13!n2!n 20 "1-2, Branch identifier positions: 3-5" "2!n, Branch identifier length: 3!n" "10, Branch identifier example: 006" 10006035183598478831 0 TN592!n3!n13!n2!n 24 TN5910006035183598478831 TN59 1000 6035 1835 9847 8831 No "Tunisia’s Professional Association for Banks & Financial Institutions, Tel: (+216) 71 904 423, Fax: (+216) 71 903 846, Email: info@apbt.org.tn"
67
+ Turkey TR 0061 01299 1234567890123456789 0 5!n1!c16!c 22 Positions 1-5 5!n 00061 0006100519786457841326 0 TR2!n5!n1!c16!c 26 TR330006100519786457841326 TR33 0006 1005 1978 6457 8413 26 No "Mr Ibrahim Kirdaban, Deputy Executive Director, Central Bank of the Republic of Turkey, Payment Systems Department, Telephone: +90 312 507 79 09, Fax: +90 312 507 79 49, e-mail: ibrahim.kirdaban@tcmb.gov.tr, Website: http://www.tcmb.gov.tr/yeni/eng/"
68
+ United Arab Emirates AE 1234567890123456 0 3!n16!n 19 Positions 1-3 ;Branch is not available 3!n 33 0331234567890123456 0 AE2!n3!n16!n 23 AE070331234567890123456 AE07 0331 2345 6789 0123 456 No Mr. Rashid Mohamed Al Fandi Executive Director Banking Operations Tel:+971 2 691 5424 or +971 2 666 8486 Fax:+971 2 666 7327 email: rashed.alfandi@cbuae.gov.ae or Mr Thomson Robert. Chief Manager Dept ITPU Tel: +971 2 691 5202 Fax: + 971 2 666 3597 Email: bob.thomson@cbuae.gov.ae
69
+ United Kingdom GB 60-16-13 31926819 0 4!a6!n8!n 18 Positions 1-4 4!a NWBK NWBK60161331926819 0 GB2!n4!a6!n8!n 22 GB29NWBK60161331926819 GB29 NWBK 6016 1331 9268 19 Yes "Mr James WHITTLE, Head of Standards, UK payments Administration, Mercury House, Triton Court, 14 Finsbury Square, London EC2A 1LQ, Tel: +44 (0) 20 7711 6209, Mob: +44 (0) 7909 620189, james.whittle@ukpayments.org.uk, web: www.ukpayments.org.uk"
70
+ "Virgin Islands, British" VG 00000 12 345 678 901 0 4!a16!n 20 Positions 1-4 4!a VPVG VPVG0000012345678901 0 VG2!n4!a16!n 24 VG96VPVG0000012345678901 VG96 VPVG 0000 0123 4567 8901 "Mr. Reichenstein Peter, Managing Director, VP Bank (BVI) LTD, VP Bank House, 156 Mainstreet, VG1110, Road Town, Tortola, British Virgin Islands, Telephone: +1 284 494 11 00, Fax: +1 284 494 11 99, e-mail: peter.reichenstein@vpbank.com"
@@ -0,0 +1,43 @@
1
+ ---
2
+ BE:
3
+ :local_check_digit_position: 15
4
+ :local_check_digit_length: 2
5
+ DE:
6
+ :bban_format: \d{8}\d{10}
7
+ EE:
8
+ :local_check_digit_position: 20
9
+ :local_check_digit_length: 1
10
+ ES:
11
+ :local_check_digit_position: 13
12
+ :local_check_digit_length: 2
13
+ FI:
14
+ :bban_format: \d{6}\d{7}\d{1}
15
+ :local_check_digit_position: 18
16
+ :local_check_digit_length: 1
17
+ FR:
18
+ :local_check_digit_position: 26
19
+ :local_check_digit_length: 2
20
+ HU:
21
+ :bban_format: \d{3}\d{4}\d{1}\d{15}\d{1}
22
+ IT:
23
+ :local_check_digit_position: 5
24
+ :local_check_digit_length: 1
25
+ MC:
26
+ :local_check_digit_position: 26
27
+ :local_check_digit_length: 2
28
+ NL:
29
+ :local_check_digit_position: 18
30
+ :local_check_digit_length: 1
31
+ PT:
32
+ :local_check_digit_position: 24
33
+ :local_check_digit_length: 2
34
+ QA:
35
+ :bban_format: '[A-Z]{4}[A-Z0-9]{21}'
36
+ SK:
37
+ :local_check_digit_position: 14
38
+ :local_check_digit_length: 1
39
+ SM:
40
+ :local_check_digit_position: 5
41
+ :local_check_digit_length: 1
42
+ TL:
43
+ :bban_format: \d{3}\d{14}\d{2}
@@ -0,0 +1,24 @@
1
+ require File.expand_path('../lib/ibandit/version', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.add_development_dependency 'rspec', '~> 3.1'
5
+ gem.add_development_dependency 'rspec-its', '~> 1.1'
6
+ gem.add_development_dependency 'rubocop', '~> 0.28.0'
7
+ gem.add_development_dependency 'sax-machine', '~> 1.1'
8
+ gem.add_development_dependency 'nokogiri', '~> 1.6'
9
+
10
+ gem.authors = ['Grey Baker']
11
+ gem.description = 'Ibandit is a Ruby library for manipulating and ' \
12
+ 'validating IBANs. It allows you to construct an IBAN ' \
13
+ 'from national banking details; deconstruct an IBAN into ' \
14
+ 'national banking details; and validate an IBAN\'s check ' \
15
+ 'digits and format.'
16
+ gem.email = ['grey@gocardless.com']
17
+ gem.files = `git ls-files`.split("\n")
18
+ gem.homepage = 'https://github.com/gocardless/ibandit'
19
+ gem.licenses = ['MIT']
20
+ gem.name = 'ibandit'
21
+ gem.require_paths = ['lib']
22
+ gem.summary = 'Convert national banking details into IBANs, and vice-versa.'
23
+ gem.version = Ibandit::VERSION.dup
24
+ end
@@ -0,0 +1,16 @@
1
+ require 'ibandit/version'
2
+ require 'ibandit/errors'
3
+ require 'ibandit/iban'
4
+ require 'ibandit/iban_builder'
5
+ require 'ibandit/check_digit'
6
+
7
+ module Ibandit
8
+ class << self
9
+ attr_accessor :bic_finder
10
+
11
+ def find_bic(country_code, national_id)
12
+ raise NotImplementedError, 'BIC finder is not defined' unless @bic_finder
13
+ @bic_finder.call(country_code, national_id)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,183 @@
1
+ module Ibandit
2
+ module CheckDigit
3
+ def self.mod_97_10(string)
4
+ chars = string + '00'
5
+ digits = chars.bytes.map do |byte|
6
+ case byte
7
+ when 48..57 then byte.chr # 0..9
8
+ when 65..90 then (byte - 55).to_s # A..Z
9
+ else
10
+ raise InvalidCharacterError,
11
+ "Unexpected non-alphanumeric character '#{byte.chr}'"
12
+ end
13
+ end
14
+ remainder = digits.join.to_i % 97
15
+ format('%02d', 98 - remainder)
16
+ end
17
+
18
+ # Currently unused in this gem. This method calculates a mod 11
19
+ # check digit from the string of digits passed in. These check
20
+ # digits are used in the 1st and 2nd digits of local Spanish
21
+ # account numbers.
22
+ def self.spanish(string)
23
+ scaled_values = string.chars.map.with_index do |digit, index|
24
+ unless digit.to_i.to_s == digit
25
+ raise InvalidCharacterError,
26
+ "Unexpected non-numeric character '#{digit}'"
27
+ end
28
+ Integer(digit) * (2**index % 11)
29
+ end
30
+ result = 11 - scaled_values.inject(:+) % 11
31
+ result < 10 ? result.to_s : (11 - result).to_s
32
+ end
33
+
34
+ def self.italian(string)
35
+ odd_mapping = {
36
+ 'A' => 1, 'B' => 0, 'C' => 5, 'D' => 7, 'E' => 9, 'F' => 13,
37
+ 'G' => 15, 'H' => 17, 'I' => 19, 'J' => 21, 'K' => 2, 'L' => 4,
38
+ 'M' => 18, 'N' => 20, 'O' => 11, 'P' => 3, 'Q' => 6, 'R' => 8,
39
+ 'S' => 12, 'T' => 14, 'U' => 16, 'V' => 10, 'W' => 22, 'X' => 25,
40
+ 'Y' => 24, 'Z' => 23, '0' => 1, '1' => 0, '2' => 5, '3' => 7,
41
+ '4' => 9, '5' => 13, '6' => 15, '7' => 17, '8' => 19, '9' => 21
42
+ }
43
+
44
+ scaled_values = string.chars.map.with_index do |char, index|
45
+ if index.even?
46
+ odd_mapping[char]
47
+ else
48
+ case char.ord
49
+ when 48..57 then char.to_i # 0..9
50
+ when 65..90 then char.ord - 65 # A..Z
51
+ else
52
+ raise InvalidCharacterError,
53
+ "Unexpected non-alphanumeric character '#{char}'"
54
+ end
55
+ end
56
+ end
57
+
58
+ (scaled_values.inject(:+) % 26 + 65).chr
59
+ end
60
+
61
+ # Currently unused in this gem. This method calculates the last two digits
62
+ # of a Belgian account number when given the first ten digits.
63
+ def self.belgian(string)
64
+ remainder = string.to_i % 97
65
+ format('%02d', remainder)
66
+ end
67
+
68
+ # Currently unused in this gem. This method calculates the last digit
69
+ # of a Estonian account number when given the initial digits.
70
+ def self.estonian(string)
71
+ weights = [7, 3, 1]
72
+
73
+ scaled_values = string.reverse.chars.map.with_index do |char, index|
74
+ unless char.to_i.to_s == char
75
+ raise InvalidCharacterError,
76
+ "Unexpected non-numeric character '#{char}'"
77
+ end
78
+
79
+ char.to_i * weights[index % weights.size]
80
+ end
81
+
82
+ (scaled_values.inject(:+) % 10).to_s
83
+ end
84
+
85
+ # Currently unused in this gem. This method calculates the last digit
86
+ # of a Slovakian account number (basic) when given the initial digits.
87
+ def self.slovakian_prefix(string)
88
+ weights = [10, 5, 8, 4, 2]
89
+
90
+ scaled_values = string.chars.map.with_index do |char, index|
91
+ unless char.to_i.to_s == char
92
+ raise InvalidCharacterError,
93
+ "Unexpected non-numeric character '#{char}'"
94
+ end
95
+
96
+ char.to_i * weights[index]
97
+ end
98
+
99
+ (11 - scaled_values.inject(:+) % 11).to_s
100
+ end
101
+
102
+ # Currently unused in this gem. This method calculates the last digit
103
+ # of a Slovakian account number prefix when given the initial digits.
104
+ def self.slovakian_basic(string)
105
+ weights = [6, 3, 7, 9, 10, 5, 8, 4, 2]
106
+
107
+ scaled_values = string.chars.map.with_index do |char, index|
108
+ unless char.to_i.to_s == char
109
+ raise InvalidCharacterError,
110
+ "Unexpected non-numeric character '#{char}'"
111
+ end
112
+
113
+ char.to_i * weights[index]
114
+ end
115
+
116
+ (11 - scaled_values.inject(:+) % 11).to_s
117
+ end
118
+
119
+ # Currently unused in this gem. This method calculates the last digit
120
+ # of a Dutch account number when given the first nine digits.
121
+ def self.dutch(string)
122
+ scaled_values = string.reverse.chars.map.with_index do |char, index|
123
+ unless char.to_i.to_s == char
124
+ raise InvalidCharacterError,
125
+ "Unexpected non-numeric character '#{char}'"
126
+ end
127
+
128
+ char.to_i * (index + 2)
129
+ end
130
+
131
+ result = 11 - scaled_values.inject(:+) % 11
132
+ result < 10 ? result.to_s : (11 - result).to_s
133
+ end
134
+
135
+ # Currently unused in this gem. This method calculates the last digit
136
+ # of a Finnish account number when given the initial digits (in electronic
137
+ # format).
138
+ def self.lund(string)
139
+ weights = [2, 1]
140
+
141
+ scaled_values = string.reverse.chars.map.with_index do |char, index|
142
+ unless char.to_i.to_s == char
143
+ raise InvalidCharacterError,
144
+ "Unexpected non-numeric character '#{char}'"
145
+ end
146
+
147
+ scaled_value = char.to_i * weights[index % weights.size]
148
+ scaled_value < 10 ? scaled_value : scaled_value % 10 + 1
149
+ end
150
+
151
+ (10 - scaled_values.inject(:+) % 10).to_s
152
+ end
153
+
154
+ def self.rib(bank_code, branch_code, account_number)
155
+ remainder = 97 - (89 * rib_value(bank_code) +
156
+ 15 * rib_value(branch_code) +
157
+ 3 * rib_value(account_number)) % 97
158
+ format('%02d', remainder)
159
+ end
160
+
161
+ def self.iban(country_code, bban)
162
+ mod_97_10(bban + country_code)
163
+ end
164
+
165
+ def self.rib_value(string)
166
+ rib_mapping = {
167
+ 'A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7,
168
+ 'H' => 8, 'I' => 9, 'J' => 1, 'K' => 2, 'L' => 3, 'M' => 4, 'N' => 5,
169
+ 'O' => 6, 'P' => 7, 'Q' => 8, 'R' => 9, 'S' => 2, 'T' => 3, 'U' => 4,
170
+ 'V' => 5, 'W' => 6, 'X' => 7, 'Y' => 8, 'Z' => 9, '0' => 0, '1' => 1,
171
+ '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => 7, '8' => 8,
172
+ '9' => 9
173
+ }
174
+
175
+ string.chars.map do |character|
176
+ unless rib_mapping[character]
177
+ raise InvalidCharacterError, "Unexpected byte '#{character}' in RIB"
178
+ end
179
+ rib_mapping[character]
180
+ end.join.to_i
181
+ end
182
+ end
183
+ end
@@ -0,0 +1,5 @@
1
+ module Ibandit
2
+ class BicNotFoundError < StandardError; end
3
+ class InvalidCharacterError < StandardError; end
4
+ class UnsupportedCountryError < StandardError; end
5
+ end
@@ -0,0 +1,168 @@
1
+ require 'yaml'
2
+
3
+ module Ibandit
4
+ class IBAN
5
+ attr_reader :iban
6
+ attr_reader :errors
7
+
8
+ def self.structures
9
+ @structures ||= YAML.load_file("#{File.dirname(__FILE__)}/structures.yml")
10
+ end
11
+
12
+ def initialize(iban)
13
+ @iban = iban.to_s.gsub(/\s+/, '').upcase
14
+ @errors = {}
15
+ end
16
+
17
+ def to_s(format = :compact)
18
+ case format
19
+ when :compact then iban
20
+ when :formatted then formatted
21
+ else raise ArgumentError, "invalid format '#{format}'"
22
+ end
23
+ end
24
+
25
+ ###################
26
+ # Component parts #
27
+ ###################
28
+
29
+ def country_code
30
+ iban[0, 2]
31
+ end
32
+
33
+ def check_digits
34
+ iban[2, 2] || ''
35
+ end
36
+
37
+ def bank_code
38
+ return '' unless structure
39
+ iban.slice(
40
+ structure[:bank_code_position] - 1,
41
+ structure[:bank_code_length]
42
+ ) || ''
43
+ end
44
+
45
+ def branch_code
46
+ return '' unless structure && structure[:branch_code_length] > 0
47
+
48
+ iban.slice(
49
+ structure[:branch_code_position] - 1,
50
+ structure[:branch_code_length]
51
+ ) || ''
52
+ end
53
+
54
+ def account_number
55
+ return '' unless structure
56
+
57
+ iban.slice(
58
+ structure[:account_number_position] - 1,
59
+ structure[:account_number_length]
60
+ ) || ''
61
+ end
62
+
63
+ def iban_national_id
64
+ return '' unless structure
65
+
66
+ national_id = branch_code.nil? ? bank_code : bank_code + branch_code
67
+ national_id.slice(0, structure[:iban_national_id_length])
68
+ end
69
+
70
+ def local_check_digits
71
+ return '' unless structure && structure[:local_check_digit_position]
72
+
73
+ iban.slice(structure[:local_check_digit_position] - 1,
74
+ structure[:local_check_digit_length]
75
+ ) || ''
76
+ end
77
+
78
+ def bban
79
+ iban[4..-1] || ''
80
+ end
81
+
82
+ ###############
83
+ # Validations #
84
+ ###############
85
+
86
+ def valid?
87
+ [
88
+ valid_country_code?,
89
+ valid_characters?,
90
+ valid_check_digits?,
91
+ valid_length?,
92
+ valid_format?
93
+ ].all?
94
+ end
95
+
96
+ def valid_country_code?
97
+ if IBAN.structures.key?(country_code)
98
+ true
99
+ else
100
+ @errors[:country_code] = "'#{country_code}' is not a valid " \
101
+ 'ISO 3166-1 IBAN country code'
102
+ false
103
+ end
104
+ end
105
+
106
+ def valid_check_digits?
107
+ return unless valid_country_code? && valid_characters?
108
+
109
+ expected_check_digits = CheckDigit.iban(country_code, bban)
110
+ if check_digits == expected_check_digits
111
+ true
112
+ else
113
+ @errors[:check_digits] = 'Check digits failed modulus check. ' \
114
+ "Expected '#{expected_check_digits}', " \
115
+ "received '#{check_digits}'"
116
+ false
117
+ end
118
+ end
119
+
120
+ def valid_length?
121
+ return unless valid_country_code?
122
+
123
+ if iban.size == structure[:total_length]
124
+ true
125
+ else
126
+ @errors[:length] = "Length doesn't match SWIFT specification " \
127
+ "(expected #{structure[:total_length]} " \
128
+ "characters, received #{iban.size})"
129
+ false
130
+ end
131
+ end
132
+
133
+ def valid_characters?
134
+ if iban.scan(/[^A-Z0-9]/).any?
135
+ @errors[:characters] = 'Non-alphanumeric characters found: ' \
136
+ "#{iban.scan(/[^A-Z\d]/).join(' ')}"
137
+ false
138
+ else
139
+ true
140
+ end
141
+ end
142
+
143
+ def valid_format?
144
+ return unless valid_country_code?
145
+
146
+ if bban =~ Regexp.new(structure[:bban_format])
147
+ true
148
+ else
149
+ @errors[:format] = "Unexpected format for a #{country_code} IBAN."
150
+ false
151
+ end
152
+ end
153
+
154
+ ###################
155
+ # Private methods #
156
+ ###################
157
+
158
+ private
159
+
160
+ def structure
161
+ IBAN.structures[country_code]
162
+ end
163
+
164
+ def formatted
165
+ iban.gsub(/(.{4})/, '\1 ').strip
166
+ end
167
+ end
168
+ end