-
Notifications
You must be signed in to change notification settings - Fork 1
/
detect-bank.js
238 lines (234 loc) · 8.23 KB
/
detect-bank.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
/*
* @Name: Detect Iranian Banks
* @Author: Max Base
* @Date: 2022-02-25
* @Language: Javascript
* @Repository: https://github.com/BaseMax/DetectIranianBankJS
*/
const banks = [{
"card_no": 627381,
"bank_name": "ansar",
"bank_title": "بانک انصار",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/ansar-05.svg",
"color": "#26eeb900"
}, {
"card_no": 636214,
"bank_name": "ayandeh",
"bank_title": "بانک آینده",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/ayande-03.svg",
"color": "#3388391d"
}, {
"card_no": 502938,
"bank_name": "dey",
"bank_title": "بانک دی",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/day-12.svg",
"color": "#0dffffff"
}, {
"card_no": 627412,
"bank_name": "eghtesad_novin",
"bank_title": "بانک اقتصادنوین",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/eghtesad-04.svg",
"color": "#1a662891"
}, {
"card_no": 628157,
"bank_name": "etebari_tosee",
"bank_title": "موسسه اعتباری توسعه",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/tose-11.svg",
"color": "#33000000"
}, {
"card_no": 505416,
"bank_name": "gardeshgari",
"bank_title": "بانک گردشگری",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/gardeshgari-20.svg",
"color": "#29344143"
}, {
"card_no": 639599,
"bank_name": "ghavvamin",
"bank_title": "بانک قوامین",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/ghavvamin-31.svg",
"color": "#1afff400"
}, {
"card_no": 627488,
"bank_name": "kar_afarin",
"bank_title": "بانک کارآفرین",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/karafarin-06.svg",
"color": "#333a881d"
}, {
"card_no": 502910,
"bank_name": "kar_afarin",
"bank_title": "بانک کارآفرین",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/karafarin-06.svg",
"color": "#333a881d"
}, {
"card_no": 603770,
"bank_name": "keshavarzi",
"bank_title": "بانک کشاورزی",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/keshavarzi-07.svg",
"color": "#29aa9a22"
}, {
"card_no": 639217,
"bank_name": "keshavarzi",
"bank_title": "بانک کشاورزی",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/keshavarzi-07.svg",
"color": "#29aa9a22"
}, {
"card_no": 628023,
"bank_name": "maskan",
"bank_title": "بانک مسکن",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/maskan-26.svg",
"color": "#1a000000"
}, {
"card_no": 639370,
"bank_name": "mehr_e_eghtesad",
"bank_title": "بانک مهر اقتصاد",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/mehreghtesad-14.svg",
"color": "#1a656565"
}, {
"card_no": 606373,
"bank_name": "mehr_e_iranian",
"bank_title": "بانک قرض الحسنه مهر ایرانیان",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/mehriran-15.svg",
"color": "#1a209b1c"
}, {
"card_no": 603799,
"bank_name": "meli",
"bank_title": "بانک ملی ایران",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/melli-22.svg",
"color": "#1a00e0d7"
}, {
"card_no": 610433,
"bank_name": "mellat",
"bank_title": "بانک ملت",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/mellat-02.svg",
"color": "#1aba0b22"
}, {
"card_no": 991975,
"bank_name": "mellat",
"bank_title": "بانک ملت",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/mellat-02.svg",
"color": "#1aba0b22"
}, {
"card_no": 111111,
"bank_name": "ok",
"bank_title": "همه کارتخوانها",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/shetab.svg",
"color": "#1a00e0d7"
}, {
"card_no": 622106,
"bank_name": "parsian",
"bank_title": "بانک پارسیان",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/pasargad-21.svg",
"color": "#29980000"
}, {
"card_no": 502229,
"bank_name": "pasargad",
"bank_title": "بانک پاسارگاد",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/pasargad-10.svg",
"color": "#4d000000"
}, {
"card_no": 639347,
"bank_name": "pasargad",
"bank_title": "بانک پاسارگاد",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/pasargad-10.svg",
"color": "#4d000000"
}, {
"card_no": 627760,
"bank_name": "post_bank",
"bank_title": "پست بانک ایران",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/post-09.svg",
"color": "#1a14763e"
}, {
"card_no": 589463,
"bank_name": "refah",
"bank_title": "بانک رفاه",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/refahkargaran-28.svg",
"color": "#0d000000"
}, {
"card_no": 627961,
"bank_name": "saanat_va_maadan",
"bank_title": "بانک صنعت و معدن",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/sanatmadan-16.svg",
"color": "#339b814c"
}, {
"card_no": 603769,
"bank_name": "saderat",
"bank_title": "بانک صادرات",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/saderat-29.svg",
"color": "#1a2d2a68"
}, {
"card_no": 621986,
"bank_name": "saman",
"bank_title": "بانک سامان",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/saman-01.svg",
"color": "#1a7dcdf1"
}, {
"card_no": 639607,
"bank_name": "sarmayeh",
"bank_title": "بانک سرمایه",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/sarmaye-17.svg",
"color": "#29bd9ff5"
}, {
"card_no": 589210,
"bank_name": "sepah",
"bank_title": "بانک سپه",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/sepah-24.svg",
"color": "#33ffc400"
}, {
"card_no": 504706,
"bank_name": "shahr",
"bank_title": "بانک شهر",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/shahr-25.svg",
"color": "#29ffafb2"
}, {
"card_no": 502806,
"bank_name": "shahr",
"bank_title": "بانک شهر",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/shahr-25.svg",
"color": "#29ffafb2"
}, {
"card_no": 639346,
"bank_name": "sina",
"bank_title": "بانک سینا",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/sina-23.svg",
"color": "#1a277eb5"
}, {
"card_no": 627353,
"bank_name": "tejarat",
"bank_title": "بانک تجارت",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/tejarat-13.svg",
"color": "#290fadc7"
}, {
"card_no": 585983,
"bank_name": "tejarat",
"bank_title": "بانک تجارت",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/tejarat-13.svg",
"color": "#290fadc7"
}, {
"card_no": 636949,
"bank_name": "tejarat",
"bank_title": "بانک حکمت",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/hekmat-30.svg",
"color": "#29563288"
}, {
"card_no": 627648,
"bank_name": "tosee_saderat",
"bank_title": "بانک توسعه صادرات",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/tosesaderat-18.svg",
"color": "#1f6d6900"
}, {
"card_no": 502908,
"bank_name": "tosee_taavon",
"bank_title": "بانک توسعه تعاون",
"bank_logo": "https://basemax.github.io/DetectIranianBankWeb/images/tosetaavon-19.svg",
"color": "#290076ff"
}];
const detect_bank = (card_number) => {
const onlyNum = str => str.replace(/[^.\d]/g, '');
card_number = onlyNum(String(card_number));
if (card_number.length < 6) return undefined;
card_number_prefix = parseInt(card_number.substr(0, 6));
const bank = banks.filter(b => b.card_no === card_number_prefix);
return bank.length === 0 ? undefined : bank[0];
};
console.log(detect_bank("63934610"));
console.log(detect_bank("111163934610"));