clabe_mx 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/clabe.rb +586 -0
  3. metadata +58 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 74415a41de9cd2ada81a3acdc40a7b2b941c646a7d44dc8ac11ae129d106d83f
4
+ data.tar.gz: 89d0e366c5c0923abf30957fa5886cc7a1dfa46f2380481358c9280cb2e35cba
5
+ SHA512:
6
+ metadata.gz: b2dc3867e0e3e37a3545d7b070ee8bcd43083492d150c1a681d840ab0a0a836eb344462fa67dd25c1c8c39cd500348291534ea89af752bd7ae7a86ae8c21c8d7
7
+ data.tar.gz: 23e486263d1d596168110d12a608642fefffb34e742e861256356a43e6d92c491c6f3d54a7991285d8372ad846727d31a538278ea7206ca5b2b61c0b8cecf29a
@@ -0,0 +1,586 @@
1
+ module Clabe
2
+ ClabeValidation = Struct.new(:is_valid?, :bank_tag, :bank_name, :bank_code, :city, :errors)
3
+
4
+ BANKS = {
5
+ "002" => { tag: 'BANAMEX', name: 'Banco Nacional de México, S.A.' },
6
+ "006" => { tag: 'BANCOMEXT', name: 'Banco Nacional de Comercio Exterior' },
7
+ "009" => { tag: 'BANOBRAS', name: 'Banco Nacional de Obras y Servicios Públicos' },
8
+ "012" => { tag: 'BBVA BANCOMER', name: 'BBVA Bancomer, S.A.' },
9
+ "014" => { tag: 'SANTANDER', name: 'Banco Santander, S.A.' },
10
+ "019" => { tag: 'BANJERCITO', name: 'Banco Nacional del Ejército, Fuerza Aérea y Armada' },
11
+ "021" => { tag: 'HSBC', name: 'HSBC México, S.A.' },
12
+ "022" => { tag: 'GE MONEY', name: 'GE Money Bank, S.A.' },
13
+ "030" => { tag: 'BAJÍO', name: 'Banco del Bajío, S.A.' },
14
+ "032" => { tag: 'IXE', name: 'IXE Banco, S.A.' },
15
+ "036" => { tag: 'INBURSA', name: 'Banco Inbursa, S.A.' },
16
+ "037" => { tag: 'INTERACCIONES', name: 'Banco Interacciones, S.A.' },
17
+ "042" => { tag: 'MIFEL', name: 'Banca Mifel, S.A.' },
18
+ "044" => { tag: 'SCOTIABANK', name: 'Scotiabank Inverlat, S.A.' },
19
+ "058" => { tag: 'BANREGIO', name: 'Banco Regional de Monterrey, S.A.' },
20
+ "059" => { tag: 'INVEX', name: 'Banco Invex, S.A.' },
21
+ "060" => { tag: 'BANSI', name: 'Bansi, S.A.' },
22
+ "062" => { tag: 'AFIRME', name: 'Banca Afirme, S.A.' },
23
+ "072" => { tag: 'BANORTE', name: 'Banco Mercantil del Norte, S.A.' },
24
+ "102" => { tag: 'ABNAMRO', name: 'ABN AMRO Bank México, S.A.' },
25
+ "103" => { tag: 'AMERICAN EXPRESS', name: 'American Express Bank (México), S.A.' },
26
+ "106" => { tag: 'BAMSA', name: 'Bank of America México, S.A.' },
27
+ "108" => { tag: 'TOKYO', name: 'Bank of Tokyo-Mitsubishi UFJ (México), S.A.' },
28
+ "110" => { tag: 'JP MORGAN', name: 'Banco J.P. Morgan, S.A.' },
29
+ "112" => { tag: 'BMONEX', name: 'Banco Monex, S.A.' },
30
+ "113" => { tag: 'VE POR MAS', name: 'Banco Ve por Mas, S.A.' },
31
+ "116" => { tag: 'ING', name: 'ING Bank (México), S.A.' },
32
+ "124" => { tag: 'DEUTSCHE', name: 'Deutsche Bank México, S.A.' },
33
+ "126" => { tag: 'CREDIT SUISSE', name: 'Banco Credit Suisse (México), S.A.' },
34
+ "127" => { tag: 'AZTECA', name: 'Banco Azteca, S.A.' },
35
+ "128" => { tag: 'AUTOFIN', name: 'Banco Autofin México, S.A.' },
36
+ "129" => { tag: 'BARCLAYS', name: 'Barclays Bank México, S.A.' },
37
+ "130" => { tag: 'COMPARTAMOS', name: 'Banco Compartamos, S.A.' },
38
+ "131" => { tag: 'FAMSA', name: 'Banco Ahorro Famsa, S.A.' },
39
+ "132" => { tag: 'BMULTIVA', name: 'Banco Multiva, S.A.' },
40
+ "133" => { tag: 'PRUDENTIAL', name: 'Prudencial Bank, S.A.' },
41
+ "134" => { tag: 'WAL-MART', name: 'Banco Wal Mart de México Adelante, S.A.' },
42
+ "135" => { tag: 'NAFIN', name: 'Nacional Financiera, S.N.C.' },
43
+ "136" => { tag: 'REGIONAL', name: 'Banco Regional, S.A.' },
44
+ "137" => { tag: 'BANCOPPEL', name: 'BanCoppel, S.A.' },
45
+ "138" => { tag: 'ABC CAPITAL', name: 'ABC Capital, S.A. I.B.M.' },
46
+ "139" => { tag: 'UBS BANK', name: 'UBS Banco, S.A.' },
47
+ "140" => { tag: 'FÁCIL', name: 'Banco Fácil, S.A.' },
48
+ "141" => { tag: 'VOLKSWAGEN', name: 'Volkswagen Bank S.A. Institución de Banca Múltiple' },
49
+ "143" => { tag: 'CIBANCO', name: 'Consultoría Internacional Banco, S.A.' },
50
+ "145" => { tag: 'BBASE', name: 'Banco BASE, S.A. de I.B.M.' },
51
+ "147" => { tag: 'BANKAOOL', name: 'Bankaool, S.A., Institución de Banca Múltiple' },
52
+ "148" => { tag: 'PAGATODO', name: 'Banco PagaTodo S.A., Institución de Banca Múltiple' },
53
+ "150" => { tag: 'BIM', name: 'Banco Inmobiliario Mexicano, S.A., Institución de Banca Múltiple' },
54
+ "152" => { tag: 'BANCREA', name: 'Banco Bancrea, S.A., Institución de Banca Múltiple' },
55
+ "156" => { tag: 'SABADELL', name: 'Banco Sabadell, S.A. I.B.M.' },
56
+ "166" => { tag: 'BANSEFI', name: 'Banco del Ahorro Nacional y Servicios Financieros, S.N.C.' },
57
+ "168" => { tag: 'HIPOTECARIA FEDERAL', name: 'Sociedad Hipotecaria Federal, S.N.C.' },
58
+ "600" => { tag: 'MONEXCB', name: 'Monex Casa de Bolsa, S.A. de C.V.' },
59
+ "601" => { tag: 'GBM', name: 'GBM Grupo Bursátil Mexicano, S.A. de C.V.' },
60
+ "602" => { tag: 'MASARI CC.', name: 'Masari Casa de Cambio, S.A. de C.V.' },
61
+ "604" => { tag: 'C.B. INBURSA', name: 'Inversora Bursátil, S.A. de C.V.' },
62
+ "605" => { tag: 'VALUÉ', name: 'Valué, S.A. de C.V., Casa de Bolsa' },
63
+ "606" => { tag: 'CB BASE', name: 'Base Internacional Casa de Bolsa, S.A. de C.V.' },
64
+ "607" => { tag: 'TIBER', name: 'Casa de Cambio Tiber, S.A. de C.V.' },
65
+ "608" => { tag: 'VECTOR', name: 'Vector Casa de Bolsa, S.A. de C.V.' },
66
+ "610" => { tag: 'B&B', name: 'B y B Casa de Cambio, S.A. de C.V.' },
67
+ "611" => { tag: 'INTERCAM', name: 'Intercam Casa de Cambio, S.A. de C.V.' },
68
+ "613" => { tag: 'MULTIVA', name: 'Multivalores Casa de Bolsa, S.A. de C.V. Multiva Gpo. Fin.' },
69
+ "614" => { tag: 'ACCIVAL', name: 'Acciones y Valores Banamex, S.A. de C.V., Casa de Bolsa' },
70
+ "615" => { tag: 'MERRILL LYNCH', name: 'Merrill Lynch México, S.A. de C.V., Casa de Bolsa' },
71
+ "616" => { tag: 'FINAMEX', name: 'Casa de Bolsa Finamex, S.A. de C.V.' },
72
+ "617" => { tag: 'VALMEX', name: 'Valores Mexicanos Casa de Bolsa, S.A. de C.V.' },
73
+ "618" => { tag: 'ÚNICA', name: 'Única Casa de Cambio, S.A. de C.V.' },
74
+ "619" => { tag: 'ASEGURADORA MAPFRE', name: 'MAPFRE Tepeyac S.A.' },
75
+ "620" => { tag: 'AFORE PROFUTURO', name: 'Profuturo G.N.P., S.A. de C.V.' },
76
+ "621" => { tag: 'CB ACTINBER', name: 'Actinver Casa de Bolsa, S.A. de C.V.' },
77
+ "622" => { tag: 'ACTINVE SI', name: 'Actinver S.A. de C.V.' },
78
+ "623" => { tag: 'SKANDIA', name: 'Skandia Vida S.A. de C.V.' },
79
+ "624" => { tag: 'CONSULTORÍA', name: 'Consultoría Internacional Casa de Cambio, S.A. de C.V.' },
80
+ "626" => { tag: 'CBDEUTSCHE', name: 'Deutsche Securities, S.A. de C.V.' },
81
+ "627" => { tag: 'ZURICH', name: 'Zurich Compañía de Seguros, S.A.' },
82
+ "628" => { tag: 'ZURICHVI', name: 'Zurich Vida, Compañía de Seguros, S.A.' },
83
+ "629" => { tag: 'HIPOTECARIA SU CASITA', name: 'Hipotecaria su Casita, S.A. de C.V.' },
84
+ "630" => { tag: 'C.B. INTERCAM', name: 'Intercam Casa de Bolsa, S.A. de C.V.' },
85
+ "631" => { tag: 'C.B. VANGUARDIA', name: 'Vanguardia Casa de Bolsa, S.A. de C.V.' },
86
+ "632" => { tag: 'BULLTICK C.B.', name: 'Bulltick Casa de Bolsa, S.A. de C.V.' },
87
+ "633" => { tag: 'STERLING', name: 'Sterling Casa de Cambio, S.A. de C.V.' },
88
+ "634" => { tag: 'FINCOMUN', name: 'Fincomún, Servicios Financieros Comunitarios, S.A. de C.V.' },
89
+ "636" => { tag: 'HDI SEGUROS', name: 'HDI Seguros, S.A. de C.V.' },
90
+ "637" => { tag: 'ORDER', name: 'OrderExpress Casa de Cambio , S.A. de C.V. AAC' },
91
+ "638" => { tag: 'AKALA', name: 'Akala, S.A. de C.V., Sociedad Financiera Popular' },
92
+ "640" => { tag: 'JP MORGAN C.B.', name: 'J.P. Morgan Casa de Bolsa, S.A. de C.V.' },
93
+ "642" => { tag: 'REFORMA', name: 'Operadora de Recursos Reforma, S.A. de C.V.' },
94
+ "646" => { tag: 'STP', name: 'Sistema de Transferencias y Pagos STP, S.A. de C.V., SOFOM E.N.R.' },
95
+ "647" => { tag: 'TELECOMM', name: 'Telecomunicaciones de México' },
96
+ "648" => { tag: 'EVERCORE', name: 'Evercore Casa de Bolsa, S.A. de C.V.' },
97
+ "649" => { tag: 'SKANDIA', name: 'Skandia Operadora S.A. de C.V.' },
98
+ "651" => { tag: 'SEGMTY', name: 'Seguros Monterrey New York Life, S.A de C.V.' },
99
+ "652" => { tag: 'ASEA', name: 'Solución Asea, S.A. de C.V., Sociedad Financiera Popular' },
100
+ "653" => { tag: 'KUSPIT', name: 'Kuspit Casa de Bolsa, S.A. de C.V.' },
101
+ "655" => { tag: 'SOFIEXPRESS', name: 'J.P. SOFIEXPRESS, S.A. de C.V., S.F.P.' },
102
+ "656" => { tag: 'UNAGRA', name: 'UNAGRA, S.A. de C.V., S.F.P.' },
103
+ "659" => { tag: 'OPCIONES EMPRESARIALES DEL NOROESTE', name: 'Opciones Empresariales Del Noreste, S.A. DE C.V.' },
104
+ "670" => { tag: 'LIBERTAD', name: 'Libertad Servicios Financieros, S.A. De C.V.' },
105
+ "846" => { tag: 'STP', name: 'Sistema de Transferencias y Pagos STP'},
106
+ "901" => { tag: 'CLS', name: 'CLS Bank International' },
107
+ "902" => { tag: 'INDEVAL', name: 'SD. INDEVAL, S.A. de C.V.' },
108
+ "999" => { tag: 'N/A', name: 'N/A' }
109
+ }.freeze
110
+
111
+ CITIES = {
112
+ "010" => "Aguascalientes",
113
+ "012" => "Calvillo",
114
+ "014" => "Jesús María",
115
+ "020" => "Mexicali",
116
+ "022" => "Ensenada",
117
+ "027" => "Tecate, Tijuana",
118
+ "028" => "La Mesa, Rosarito, Tijuana",
119
+ "040" => "La Paz",
120
+ "041" => "Cabo San Lucas",
121
+ "042" => "Ciudad Constitución",
122
+ "043" => "Guerrero Negro",
123
+ "045" => "San José del Cabo",
124
+ "046" => "Santa Rosalía",
125
+ "050" => "Campeche",
126
+ "051" => "Calkiní",
127
+ "052" => "Ciudad del Carmen",
128
+ "053" => "Champotón",
129
+ "060" => "Gómez Palacio, Torreón",
130
+ "062" => "Ciudad Acuña",
131
+ "068" => "Monclova",
132
+ "071" => "Nava",
133
+ "072" => "Nueva Rosita",
134
+ "074" => "Parras de la Fuente",
135
+ "075" => "Piedras Negras",
136
+ "076" => "Ramos Arizpe",
137
+ "077" => "Sabinas",
138
+ "078" => "Saltillo",
139
+ "080" => "San Pedro de las Colonias",
140
+ "090" => "Colima",
141
+ "095" => "Manzanillo",
142
+ "097" => "Tecomán",
143
+ "100" => "Terán, Tuxtla Gutiérrez",
144
+ "103" => "Arriaga",
145
+ "107" => "Cintalapa",
146
+ "109" => "Comitán, Villa Las Rosas",
147
+ "111" => "Chiapa de Corso",
148
+ "113" => "F. Comalapa",
149
+ "114" => "Huixtla",
150
+ "123" => "Ocosingo",
151
+ "124" => "Ocozocuautla",
152
+ "125" => "Palenque",
153
+ "126" => "Pichucalco",
154
+ "127" => "Pijijiapan",
155
+ "128" => "Reforma",
156
+ "130" => "San Cristóbal de las Casas",
157
+ "131" => "Simojovel",
158
+ "133" => "Tapachula",
159
+ "135" => "Tonala",
160
+ "137" => "Venustiano Carranza",
161
+ "138" => "Villa Flores",
162
+ "140" => "Yajalón",
163
+ "150" => "Chihuahua, Ciudad Delicias",
164
+ "152" => "Ciudad Anáhuac",
165
+ "155" => "Ciudad Camargo",
166
+ "158" => "Ciudad Cuauhtémoc",
167
+ "161" => "Ciudad Guerrero",
168
+ "162" => "Parral",
169
+ "163" => "Ciudad Jiménez",
170
+ "164" => "Ciudad Juárez",
171
+ "165" => "Ciudad Madera",
172
+ "167" => "El Molino de Namiquipa",
173
+ "168" => "Nuevo Casas Grandes",
174
+ "180" => "Atizapan, Chalco, Ciudad de México, Coacalco, Cuautitlán, Cuautitlán Izcalli, Ecatepec, Huehuetoca, Huixquilucan, Ixtapaluca, Los Reyes La Paz, Naucalpan, Nezahualcóyotl, Tecamac, Teotihuacán, Texcoco, Tlalnepantla",
175
+ "190" => "Durango",
176
+ "201" => "Tepehuanes",
177
+ "202" => "Vicente Guerrero",
178
+ "210" => "Guanajuato",
179
+ "211" => "Abasolo",
180
+ "212" => "Acámbaro",
181
+ "213" => "Apaseo el Alto",
182
+ "214" => "Apaseo el Grande",
183
+ "215" => "Celaya",
184
+ "216" => "Comonfort",
185
+ "217" => "Coroneo",
186
+ "218" => "Cortazar",
187
+ "219" => "Cuerámaro",
188
+ "220" => "Dolores Hidalgo",
189
+ "222" => "Irapuato",
190
+ "223" => "Jaral del Progreso",
191
+ "224" => "Jerécuaro",
192
+ "225" => "León",
193
+ "226" => "Cd. Manuel Doblado",
194
+ "227" => "Moroleón",
195
+ "229" => "Pénjamo",
196
+ "232" => "Romita",
197
+ "233" => "Salamanca",
198
+ "234" => "Salvatierra",
199
+ "236" => "San Felipe",
200
+ "237" => "Purísima de Bustos, San Francisco del Rincoón",
201
+ "238" => "San José Iturbide",
202
+ "239" => "San Luis de la Paz",
203
+ "240" => "San Miguel Allende",
204
+ "244" => "Silao",
205
+ "247" => "Uriangato",
206
+ "248" => "Valle de Santiago",
207
+ "249" => "Yuriria",
208
+ "260" => "Chilpancingo",
209
+ "261" => "Acapulco",
210
+ "263" => "Arcelia",
211
+ "264" => "Atoyac de Álvarez",
212
+ "266" => "Ciudad Altamirano",
213
+ "267" => "Coyuca de Benítez",
214
+ "270" => "Chilapa",
215
+ "271" => "Huitzuco",
216
+ "272" => "Iguala, La Sabana",
217
+ "274" => "Cuajinicuilapa, Ometepec",
218
+ "275" => "San Marcos",
219
+ "276" => "Taxco",
220
+ "278" => "Teloloapan",
221
+ "281" => "Tlapa",
222
+ "282" => "Ixtapa Zihuatanejo, Zihuatanejo",
223
+ "290" => "Pachuca",
224
+ "291" => "Actopan",
225
+ "292" => "Apam",
226
+ "293" => "Atotonilco el Grande",
227
+ "294" => "Ciudad Sahagún, Teocaltiche",
228
+ "295" => "Cuautepec",
229
+ "296" => "Huejutla",
230
+ "297" => "Huichapan",
231
+ "298" => "Ixmiquilpan",
232
+ "303" => "Progreso de Obregón",
233
+ "305" => "Tepeapulco",
234
+ "308" => "Tizayuca",
235
+ "311" => "Tula de Allende",
236
+ "312" => "Tulancingo",
237
+ "313" => "Zacualtipán",
238
+ "314" => "Zimapán",
239
+ "320" => "El Salto, Guadalajara, San Pedro Tlaquepaque, Tlajomulco, Tonala, Zapopan",
240
+ "326" => "Ameca",
241
+ "327" => "Arandas",
242
+ "330" => "Atotonilco el Alto",
243
+ "331" => "Atequiza",
244
+ "333" => "Autlán",
245
+ "340" => "Casimiro Castillo",
246
+ "341" => "Cihuatlán",
247
+ "342" => "Ciudad Guzmán",
248
+ "346" => "Chapala",
249
+ "348" => "El Grullo",
250
+ "355" => "Ixtlahuacán del Río",
251
+ "356" => "Jalostotitlán",
252
+ "357" => "Jamay",
253
+ "361" => "La Barca",
254
+ "362" => "Lagos de Moreno",
255
+ "370" => "Ocotlán",
256
+ "373" => "Pihuamo",
257
+ "375" => "Las Juntas, Nuevo Vallarta, Pitillal, Puerto Vallarta",
258
+ "381" => "San Juan de los Lagos",
259
+ "384" => "San Miguel el Alto",
260
+ "385" => "San Patricio Melaque",
261
+ "386" => "Sayula",
262
+ "387" => "Tala",
263
+ "389" => "Tamazula de Gordiano",
264
+ "391" => "Tecalitlán",
265
+ "396" => "Tepatitlán",
266
+ "397" => "Tequila",
267
+ "403" => "Tototlán",
268
+ "404" => "Túxpam",
269
+ "411" => "Villa Hidalgo",
270
+ "413" => "Zacoalco de Torres",
271
+ "414" => "Zapotiltic",
272
+ "416" => "Zapotlanejo",
273
+ "420" => "Toluca",
274
+ "421" => "Acambay",
275
+ "422" => "Almoloya de Juárez",
276
+ "424" => "Amecameca",
277
+ "425" => "Apaxco",
278
+ "426" => "Atlacomulco",
279
+ "428" => "Coatepec de Harinas",
280
+ "430" => "Chicoloapan",
281
+ "431" => "Chiconcuac",
282
+ "432" => "El Oro",
283
+ "433" => "Ixtapan de la Sal",
284
+ "434" => "Ixtlahuaca",
285
+ "435" => "Jilotepec",
286
+ "438" => "Lerma",
287
+ "441" => "Metepec",
288
+ "443" => "Otumba",
289
+ "445" => "San Mateo Atenco",
290
+ "446" => "Tejupilco",
291
+ "448" => "Temascaltepec",
292
+ "449" => "Temoaya",
293
+ "450" => "Tenancingo",
294
+ "451" => "Tenago del Valle",
295
+ "453" => "Santiago Tiangistenco",
296
+ "455" => "Tultepec",
297
+ "456" => "Tultitlán",
298
+ "457" => "Valle de Bravo",
299
+ "460" => "Villa Nicolás Romero",
300
+ "463" => "Zumpango",
301
+ "470" => "Morelia",
302
+ "472" => "Aguililla",
303
+ "476" => "Apatzingán",
304
+ "480" => "Ciudad Hidalgo",
305
+ "483" => "Cotija",
306
+ "484" => "Cuitzeo",
307
+ "492" => "Huetamo",
308
+ "493" => "Jacona",
309
+ "494" => "Jiquilpan",
310
+ "496" => "La Piedad",
311
+ "497" => "Lázaro Cárdenas",
312
+ "498" => "Los Reyes",
313
+ "499" => "Maravatío",
314
+ "501" => "Nueva Italia",
315
+ "506" => "Pátzcuaro",
316
+ "508" => "Purépero",
317
+ "509" => "Puruandiro",
318
+ "512" => "Sahuayo",
319
+ "515" => "Tacámbaro",
320
+ "517" => "Tangancícuaro",
321
+ "519" => "Tepalcatepec",
322
+ "523" => "Tlazazalca",
323
+ "528" => "Uruapan",
324
+ "533" => "Yurécuaro",
325
+ "534" => "Zacapu",
326
+ "535" => "Zamora",
327
+ "536" => "Zinapécuaro",
328
+ "537" => "Zitácuaro",
329
+ "540" => "Cuernavaca",
330
+ "542" => "Cuautla, Oaxtepec, Morelos",
331
+ "543" => "Jiutepec",
332
+ "544" => "Jojutla",
333
+ "545" => "Puente de Ixtla",
334
+ "546" => "Temixco",
335
+ "548" => "Tetecala",
336
+ "549" => "Yautepec",
337
+ "552" => "Zacatepec",
338
+ "560" => "Tepic",
339
+ "561" => "Acaponeta",
340
+ "562" => "Ahuacatlán",
341
+ "564" => "Compostela",
342
+ "566" => "Ixtlán del Río",
343
+ "571" => "San Blas",
344
+ "573" => "Santiago Ixcuintla",
345
+ "575" => "Túxpam",
346
+ "580" => "Apodaca, Cadereyta, Cd. Guadalupe, General Escobedo, Monterrey, San Nicolás de los Garza, San Pedro Garza García, Santa Catarina",
347
+ "583" => "Allende",
348
+ "592" => "General Zuazua",
349
+ "595" => "Linares",
350
+ "597" => "Montemorelos",
351
+ "599" => "Sabinas Hidalgo",
352
+ "600" => "Salinas Victoria",
353
+ "601" => "El Cercado, Villa de Santiago",
354
+ "610" => "Oaxaca",
355
+ "613" => "Tlaxiaco",
356
+ "614" => "Huajuapan de León",
357
+ "616" => "Ixtepec",
358
+ "617" => "Juchitán",
359
+ "619" => "Loma Bonita",
360
+ "620" => "Matías Romero",
361
+ "621" => "Miahuatlán",
362
+ "622" => "Ocotlán",
363
+ "624" => "Puerto Escondido",
364
+ "626" => "Salina Cruz",
365
+ "627" => "Lagunas",
366
+ "628" => "Tuxtepec",
367
+ "630" => "Pochutla",
368
+ "631" => "San Pedro Tapanatepec",
369
+ "632" => "Santa Lucía del Camino, O",
370
+ "634" => "Bahías de Huatulco",
371
+ "635" => "Santiago Juxtlahuaca",
372
+ "636" => "Pinotepa Nacional",
373
+ "637" => "Tehuantepec",
374
+ "638" => "Tlacolula",
375
+ "640" => "Zimatlán",
376
+ "650" => "Cholul, La Resurrecció, Puebla, San Baltazar Campech",
377
+ "652" => "Acatzingo",
378
+ "654" => "Atlixco",
379
+ "656" => "Cuetzalan",
380
+ "659" => "Huauchinango",
381
+ "662" => "Izúcar de Matamoros",
382
+ "667" => "San Martín Texmelucan",
383
+ "668" => "San Felipe Hueyotlipan",
384
+ "669" => "Tecamachalco",
385
+ "670" => "Tehuacán",
386
+ "671" => "San Lorenzo",
387
+ "672" => "Teziutlán",
388
+ "674" => "Xicotepec de Juárez",
389
+ "676" => "Zacatlán",
390
+ "680" => "Pedro Escobed, Querétar, Villa Corregidor",
391
+ "681" => "Amealco",
392
+ "685" => "San Juan del Río",
393
+ "686" => "Tequisquiapan",
394
+ "690" => "Chetumal",
395
+ "691" => "Cancún, Col. Puerto Juárez",
396
+ "692" => "Cozumel",
397
+ "694" => "Playa del Carmen",
398
+ "700" => "San Luis Potosí",
399
+ "703" => "Cerritos",
400
+ "705" => "Ciudad Valles",
401
+ "709" => "Matehuala",
402
+ "711" => "Río Verde",
403
+ "716" => "Tamuín",
404
+ "730" => "Culiacán",
405
+ "735" => "Concordia",
406
+ "736" => "Cosala",
407
+ "737" => "Choix",
408
+ "738" => "El Fuerte",
409
+ "739" => "Escuinapa",
410
+ "740" => "Guamúchil",
411
+ "741" => "Guasave",
412
+ "743" => "Los Mochis, Topolobampo",
413
+ "744" => "Mazatlán",
414
+ "745" => "Mocorito",
415
+ "746" => "Navolato",
416
+ "760" => "Hermosillo",
417
+ "761" => "Agua Prieta",
418
+ "765" => "Caborca",
419
+ "766" => "Cananea",
420
+ "767" => "Ciudad Obregón, Esperanza",
421
+ "769" => "Empalme",
422
+ "770" => "Guaymas, San Carlos",
423
+ "771" => "Huatabampo",
424
+ "773" => "Magdalena",
425
+ "776" => "Nacozari de García",
426
+ "777" => "Navojoa",
427
+ "778" => "Nogales",
428
+ "779" => "Puerto Peñasco",
429
+ "780" => "San Luis Río Colorado",
430
+ "790" => "Tamulte, Villa Hermosa",
431
+ "792" => "Cárdenas",
432
+ "793" => "Ciudad Pemex",
433
+ "794" => "Comalcalco",
434
+ "796" => "Emiliano Zapata",
435
+ "797" => "Frontera",
436
+ "798" => "Huimanguillo",
437
+ "800" => "Jalpa de Méndez",
438
+ "802" => "Macuspana",
439
+ "803" => "Nacajuca",
440
+ "804" => "Paraíso",
441
+ "805" => "Tacotalpa",
442
+ "806" => "Teapa",
443
+ "807" => "Tenosique",
444
+ "810" => "Ciudad Victoria",
445
+ "811" => "Altamira",
446
+ "813" => "Ciudad Madero, Tampico",
447
+ "814" => "Ciudad Mante",
448
+ "818" => "Matamoros",
449
+ "821" => "Colombia, Nuevo Laredo",
450
+ "822" => "Reynosa",
451
+ "823" => "Río Bravo",
452
+ "825" => "Soto La Marina",
453
+ "826" => "Valle Hermoso",
454
+ "830" => "Tlaxcala",
455
+ "832" => "Apizaco",
456
+ "834" => "Santa Ana Chiautempan",
457
+ "840" => "Jalapa",
458
+ "841" => "Acayucan",
459
+ "843" => "Agua Dulce",
460
+ "845" => "Álamo",
461
+ "846" => "Altotonga",
462
+ "848" => "Banderilla",
463
+ "849" => "Boca del Río",
464
+ "852" => "Ciudad Mendoza",
465
+ "853" => "Coatepec",
466
+ "854" => "Coatzacoalcos",
467
+ "855" => "Córdoba",
468
+ "856" => "Cosamaloapan",
469
+ "860" => "Cuitláhuac",
470
+ "863" => "Fortín de las Flores",
471
+ "864" => "Gutiérrez Zamora",
472
+ "865" => "Huatusco",
473
+ "867" => "Isla",
474
+ "868" => "Ixtaczoquitlán",
475
+ "869" => "Jáltipan",
476
+ "871" => "Juan Rodríguez Clara",
477
+ "872" => "Villa José Cardel",
478
+ "873" => "Las Choapas",
479
+ "875" => "Naranjos",
480
+ "876" => "Martínez de la Torre",
481
+ "877" => "Minatitlán",
482
+ "878" => "Misantla",
483
+ "879" => "Nanchital",
484
+ "882" => "Orizaba",
485
+ "885" => "Papantla",
486
+ "886" => "Perote",
487
+ "888" => "Poza Rica",
488
+ "889" => "Río Blanco",
489
+ "890" => "San Andrés Tuxtla",
490
+ "891" => "San Rafael",
491
+ "894" => "Platón Sánchez, Tantoyuca",
492
+ "895" => "Tempoal",
493
+ "898" => "Tierra Blanca",
494
+ "901" => "Tlapacoyan",
495
+ "903" => "Túxpam de Rodríguez Cano",
496
+ "905" => "Cd. Industrial Framboyan, Veracruz",
497
+ "910" => "Mérida",
498
+ "913" => "Motul",
499
+ "914" => "Oxkutzcab",
500
+ "915" => "Progreso",
501
+ "917" => "Ticul",
502
+ "918" => "Tizimín",
503
+ "920" => "Valladolid",
504
+ "930" => "Zacatecas",
505
+ "933" => "Fresnillo",
506
+ "934" => "Guadalupe",
507
+ "935" => "Jalpa",
508
+ "936" => "Jerez de G. Salinas",
509
+ "938" => "Juchipila",
510
+ "939" => "Loreto",
511
+ "946" => "Nochistlán",
512
+ "958" => "Valparaíso",
513
+ "960" => "Calera de V. Rosales"
514
+ }.freeze
515
+
516
+ CLABE_WEIGHT_FACTOR_MAP = [3, 7, 1].freeze
517
+
518
+ private_class_method def self.compute_checksum(clabe)
519
+ result = 0
520
+
521
+ clabe.split('')[0...17].each_with_index do |val, index|
522
+ result += (val.to_i * CLABE_WEIGHT_FACTOR_MAP[index % 3]) % 10
523
+ end
524
+
525
+ return ((10 - result % 10) % 10).to_s
526
+ end
527
+
528
+ private_class_method def self.get_params(clabe)
529
+ bank_code = clabe[0...3]
530
+ city_code = clabe[3...6]
531
+ account = clabe[6...17]
532
+ checksum = clabe[17...18]
533
+
534
+ bank = BANKS[bank_code]
535
+ city = CITIES[city_code]
536
+
537
+ real_checksum = compute_checksum(clabe)
538
+
539
+ return {
540
+ bank_code: bank_code,
541
+ city_code: city_code,
542
+ account: account,
543
+ checksum: checksum,
544
+ bank: bank,
545
+ city: city,
546
+ real_checksum: real_checksum
547
+ }
548
+ end
549
+
550
+ def self.validate(clabe)
551
+ clabe_params = get_params(clabe)
552
+ clabe_validation = ClabeValidation.new(false)
553
+ clabe_validation[:errors] = []
554
+
555
+ unless clabe.length == 18
556
+ clabe_validation[:errors] << 'invalid length'
557
+ end
558
+
559
+ unless (clabe =~ /[^0-9]/).nil?
560
+ clabe_validation[:errors] << 'invalid characters'
561
+ end
562
+
563
+ if clabe_params[:bank].nil?
564
+ clabe_validation[:errors] << 'invalid bank'
565
+ end
566
+
567
+ if clabe_params[:city].nil?
568
+ clabe_validation[:errors] << 'invalid city'
569
+ end
570
+
571
+ unless clabe_params[:checksum] == clabe_params[:real_checksum]
572
+ clabe_validation[:errors] << 'must have a valid control digit'
573
+ end
574
+
575
+ unless clabe_validation.errors.empty?
576
+ return clabe_validation
577
+ end
578
+
579
+ clabe_validation[:is_valid?] = true
580
+ clabe_validation[:bank_code] = clabe_params[:bank_code]
581
+ clabe_validation[:bank_tag] = clabe_params[:bank][:tag]
582
+ clabe_validation[:bank_name] = clabe_params[:bank][:name]
583
+ clabe_validation[:city] = clabe_params[:city]
584
+ return clabe_validation
585
+ end
586
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: clabe_mx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Yellowme
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-10-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.8'
27
+ description: Ruby gem to validate and get details from a CLABE
28
+ email: hola@yellowme.mx
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/clabe.rb
34
+ homepage: https://rubygems.org/gems/clabe
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 2.7.6
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: Validate and get details from a CLABE
58
+ test_files: []