credit_debit_card_number_validator 16.09.7 → 16.09.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/validator.rb +101 -101
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 806b058d0bc2424570ab4a87293a62fe412831cc
|
4
|
+
data.tar.gz: df60a74e75ea4cc4cfd88aff50f710d9d1bf7dc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d0aef9ef19bf577d6cc85d3ca6689e0f981c04ccf1ec5f7e5dd7c5fbfbed2758943f671b7ee503a1c26dbd76003a0531ca064e9d4e789cc51b761f0bb3f74a3
|
7
|
+
data.tar.gz: b364c803ed7d0c0d1adea96cb771e9e8e844a6be7c493a845fb1b7d7d01c55b7c403a72d461fc95f6f22752895776f5d3e7a941699c1e9eda93675c728c6bf16
|
data/lib/validator.rb
CHANGED
@@ -112,123 +112,123 @@ module CreditDebitCardNumberValidator
|
|
112
112
|
iin6 = card_number[0..5]
|
113
113
|
|
114
114
|
# test all IIN Ranges of supported brands
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
elsif (
|
128
|
-
[
|
129
|
-
# {'IIN' =>
|
115
|
+
if (('560221'..'560225').include? (iin6)) && length == 16
|
116
|
+
[iin6.to_i, 'Bankcard']
|
117
|
+
# {'IIN' => iin6.to_i, 'Brand Name' => 'Bankcard'}
|
118
|
+
elsif (('622126'..'622925').include? (iin6)) && length == 16
|
119
|
+
[iin6.to_i, 'Discover Card']
|
120
|
+
# {'IIN' => iin6.to_i, 'Brand Name' => 'Discover Card'}
|
121
|
+
elsif iin6 == '357266' && length == 19
|
122
|
+
[iin6.to_i, 'JCB']
|
123
|
+
# {'IIN' => iin6.to_i, 'Brand Name' => 'JCB'}
|
124
|
+
elsif (['633312', '633110', '633304', '633303', '633301', '633300'].include? (iin6)) && (length == 16 || length == 18 || length == 19)
|
125
|
+
[iin6.to_i, 'Switch']
|
126
|
+
# {'IIN' => iin6.to_i, 'Brand Name' => 'Switch'}
|
127
|
+
elsif (('506099'..'506198').include? (iin6)) || (('650002'..'650027').include? (iin6)) && (length == 16 || length == 19)
|
128
|
+
[iin6.to_i, 'Verve']
|
129
|
+
# {'IIN' => iin6.to_i, 'Brand Name' => 'Verve'}
|
130
|
+
elsif iin6 == '417500' && (length == 13 || length == 16)
|
131
|
+
[iin6.to_i, 'Visa Electron']
|
132
|
+
# {'IIN' => iin6.to_i, 'Brand Name' => 'Visa Electron'}
|
133
|
+
elsif iin4 == '5610' && length == 16
|
134
|
+
[iin4.to_i, 'Bankcard']
|
135
|
+
# {'IIN' => iin4.to_i, 'Brand Name' => 'Bankcard'}
|
136
|
+
elsif iin4 == '5392' && length == 16
|
137
|
+
[iin4.to_i, 'CARDGUARD']
|
138
|
+
# {'IIN' => iin4.to_i, 'Brand Name' => 'CARDGUARD'}
|
130
139
|
elsif iin4 == '5019' && length == 16
|
131
140
|
[iin4.to_i, 'Dankort']
|
132
|
-
# {'IIN' => iin4.to_i, '
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
141
|
+
# {'IIN' => iin4.to_i, 'Brand Name' => 'Dankort'}
|
142
|
+
elsif (['2014', '2149'].include? (iin4)) && length == 15
|
143
|
+
[iin4.to_i, 'Diners Club Carte enRoute']
|
144
|
+
# {'IIN' => iin4.to_i, 'Brand Name' => 'Diners Club Carte enRoute'}
|
145
|
+
elsif iin4 == '6011' && length == 16
|
146
|
+
[iin4.to_i, 'Discover Card']
|
147
|
+
# {'IIN' => iin4.to_i, 'Brand Name' => 'Discover Card'}
|
148
|
+
elsif ((('3528'..'3589').include? (iin4)) || (['3088', '3096', '3112', '3158', '3337'].include? (iin4))) && (length == 15 || length == 16)
|
149
|
+
[iin4.to_i, 'JCB']
|
150
|
+
# {'IIN' => iin4.to_i, 'Brand Name' => 'JCB'}
|
151
|
+
elsif (['1800', '2131'].include? (iin4)) && length == 15
|
152
|
+
[iin4.to_i, 'JCB']
|
153
|
+
# {'IIN' => iin4.to_i, 'Brand Name' => 'JCB'}
|
154
|
+
elsif (['6304', '6706', '6771', '6709'].include? (iin4)) && (length >= 16 && length <= 19)
|
155
|
+
[iin4.to_i, 'Laser']
|
156
|
+
# {'IIN' => iin4.to_i, 'Brand Name' => 'Laser'}
|
157
|
+
elsif ((('5010'..'5018').include? (iin4)) || (('6012'..'6019').include? (iin4)) || (('6760'..'6766').include? (iin4)) || (('6768'..'6771').include? (iin4)) || (['6060', '6304', '6390', '6010'].include? (iin4))) && (length >= 12 && length <= 19)
|
158
|
+
[iin4.to_i, 'Maestro']
|
159
|
+
# {'IIN' => iin4.to_i, 'Brand Name' => 'Maestro'}
|
160
|
+
elsif ((('2221'..'2229').include? (iin4)) || iin4 == '2720') && length == 16
|
161
|
+
[iin4.to_i, 'Master Card']
|
162
|
+
# {'IIN' => iin4.to_i, 'Brand Name' => 'Master Card'}
|
163
|
+
elsif (('6061'..'6069').include? (iin4)) && length == 16
|
164
|
+
[iin4.to_i, 'RuPay']
|
165
|
+
# {'IIN' => iin4.to_i, 'Brand Name' => 'RuPay'}
|
166
|
+
elsif (['6334', '6767'].include? (iin4)) && (length == 16 || length == 18 || length == 19)
|
167
|
+
[iin4.to_i, 'Solo']
|
168
|
+
# {'IIN' => iin4.to_i, 'Brand Name' => 'Solo'}
|
169
|
+
elsif (['4903', '4905', '4911', '4936', '6333', '6759'].include? (iin4)) && (length == 16 || length == 18 || length == 19)
|
170
|
+
[iin4.to_i, 'Switch']
|
171
|
+
# {'IIN' => iin4.to_i, 'Brand Name' => 'Switch'}
|
172
|
+
elsif (['4026', '4508', '4844', '4913', '4917'].include? (iin4)) && (length == 13 || length == 16)
|
173
|
+
[iin4.to_i, 'Visa Electron']
|
174
|
+
# {'IIN' => iin4.to_i, 'Brand Name' => 'Visa Electron'}
|
175
|
+
elsif iin4 == '8699' && length == 15
|
176
|
+
[iin4.to_i, 'Voyager']
|
177
|
+
# {'IIN' => iin4.to_i, 'Brand Name' => 'Voyager'}
|
178
|
+
elsif (['622', '624', '625', '626', '628'].include? (iin3)) && (length >= 16 && length <= 19)
|
179
|
+
[iin3.to_i, 'China UnionPay']
|
180
|
+
# {'IIN' => iin3.to_i, 'Brand Name' => 'China UnionPay'}
|
181
|
+
elsif (('301'..'305').include? (iin3)) && length == 14
|
182
|
+
[iin3.to_i, 'Diners Club Carte Blanche']
|
183
|
+
# {'IIN' => iin3.to_i, 'Brand Name' => 'Diners Club Carte Blanche'}
|
184
|
+
elsif iin3 == '309' && length == 14
|
185
|
+
[iin3.to_i, 'Diners Club International']
|
186
|
+
# {'IIN' => iin3.to_i, 'Brand Name' => 'Diners Club International'}
|
187
|
+
elsif (('644'..'649').include? (iin3)) && length == 16
|
188
|
+
[iin3.to_i, 'Discover Card']
|
189
|
+
# {'IIN' => iin3.to_i, 'Brand Name' => 'Discover Card'}
|
157
190
|
elsif iin3 == '384' && length == 19
|
158
191
|
[iin3.to_i, 'Hipercard']
|
159
|
-
# {'IIN' => iin3.to_i, '
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
192
|
+
# {'IIN' => iin3.to_i, 'Brand Name' => 'Hipercard'}
|
193
|
+
elsif (('637'..'639').include? (iin3)) && length == 16
|
194
|
+
[iin3.to_i, 'InstaPayment']
|
195
|
+
# {'IIN' => iin3.to_i, 'Brand Name' => 'InstaPayment'}
|
196
|
+
elsif iin3 == '636' && (length >= 16 && length <= 19)
|
197
|
+
[iin3.to_i, 'InterPayment']
|
198
|
+
# {'IIN' => iin3.to_i, 'Brand Name' => 'InterPayment'}
|
166
199
|
elsif (('353'..'358').include? (iin3)) && (length == 15 || length == 16)
|
167
200
|
[iin3.to_i, 'JCB']
|
168
|
-
# {'IIN' => iin3.to_i, '
|
169
|
-
elsif ((('3528'..'3589').include? (iin4)) || (['3088', '3096', '3112', '3158', '3337'].include? (iin4))) && (length == 15 || length == 16)
|
170
|
-
[iin4.to_i, 'JCB']
|
171
|
-
# {'IIN' => iin4.to_i, 'Company Name' => 'JCB'}
|
172
|
-
elsif (['1800', '2131'].include? (iin4)) && length == 15
|
173
|
-
[iin4.to_i, 'JCB']
|
174
|
-
# {'IIN' => iin4.to_i, 'Company Name' => 'JCB'}
|
175
|
-
elsif iin6 == '357266' && length == 19
|
176
|
-
[iin6.to_i, 'JCB']
|
177
|
-
# {'IIN' => iin6.to_i, 'Company Name' => 'JCB'}
|
178
|
-
elsif (['6304', '6706', '6771', '6709'].include? (iin4)) && (length >= 16 && length <= 19)
|
179
|
-
[iin4.to_i, 'Laser']
|
180
|
-
# {'IIN' => iin4.to_i, 'Company Name' => 'Laser'}
|
181
|
-
elsif (('56'..'59').include? (iin2)) && (length >= 12 && length <= 19)
|
182
|
-
[iin2.to_i, 'Maestro']
|
183
|
-
# {'IIN' => iin2.to_i, 'Company Name' => 'Maestro'}
|
201
|
+
# {'IIN' => iin3.to_i, 'Brand Name' => 'JCB'}
|
184
202
|
elsif ((('502'..'509').include? (iin3)) || (('602'..'605').include? (iin3)) || (('671'..'675').include? (iin3)) || (['500', '621', '627', '629', '677', '679'].include? (iin3))) && (length >= 12 && length <= 19)
|
185
203
|
[iin3.to_i, 'Maestro']
|
186
|
-
# {'IIN' => iin3.to_i, '
|
187
|
-
elsif ((('5010'..'5018').include? (iin4)) || (('6012'..'6019').include? (iin4)) || (('6760'..'6766').include? (iin4)) || (('6768'..'6771').include? (iin4)) || (['6060', '6304', '6390', '6010'].include? (iin4))) && (length >= 12 && length <= 19)
|
188
|
-
[iin4.to_i, 'Maestro']
|
189
|
-
# {'IIN' => iin4.to_i, 'Company Name' => 'Maestro'}
|
190
|
-
elsif ((('51'..'55').include? (iin2)) || (('23'..'26').include? (iin2))) && length == 16
|
191
|
-
[iin2.to_i, 'Master Card']
|
192
|
-
# {'IIN' => iin2.to_i, 'Company Name' => 'Master Card'}
|
204
|
+
# {'IIN' => iin3.to_i, 'Brand Name' => 'Maestro'}
|
193
205
|
elsif ((('223'..'229').include? (iin3)) || iin3 == '271') && length == 16
|
194
206
|
[iin3.to_i, 'Master Card']
|
195
|
-
# {'IIN' => iin3.to_i, '
|
196
|
-
elsif ((('2221'..'2229').include? (iin4)) || iin4 == '2720') && length == 16
|
197
|
-
[iin4.to_i, 'Master Card']
|
198
|
-
# {'IIN' => iin4.to_i, 'Company Name' => 'Master Card'}
|
207
|
+
# {'IIN' => iin3.to_i, 'Brand Name' => 'Master Card'}
|
199
208
|
elsif (['607', '608'].include? (iin3)) && length == 16
|
200
209
|
[iin3.to_i, 'RuPay']
|
201
|
-
# {'IIN' => iin3.to_i, '
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
elsif (['
|
206
|
-
[
|
207
|
-
# {'IIN' =>
|
208
|
-
elsif
|
209
|
-
[
|
210
|
-
# {'IIN' =>
|
211
|
-
|
212
|
-
|
213
|
-
|
210
|
+
# {'IIN' => iin3.to_i, 'Brand Name' => 'RuPay'}
|
211
|
+
elsif (['34', '37'].include? (iin2)) && length == 15
|
212
|
+
[iin2.to_i, 'American Express']
|
213
|
+
# {'IIN' => iin2.to_i, 'Brand Name' => 'American Express'}
|
214
|
+
elsif (['36', '38', '39'].include? (iin2)) && length == 14
|
215
|
+
[iin2.to_i, 'Diners Club International']
|
216
|
+
# {'IIN' => iin2.to_i, 'Brand Name' => 'Diners Club International'}
|
217
|
+
elsif iin2 == '65' && length == 16
|
218
|
+
[iin2.to_i, 'Discover Card']
|
219
|
+
# {'IIN' => iin2.to_i, 'Brand Name' => 'Discover Card'}
|
220
|
+
elsif (('56'..'59').include? (iin2)) && (length >= 12 && length <= 19)
|
221
|
+
[iin2.to_i, 'Maestro']
|
222
|
+
# {'IIN' => iin2.to_i, 'Brand Name' => 'Maestro'}
|
223
|
+
elsif ((('51'..'55').include? (iin2)) || (('23'..'26').include? (iin2))) && length == 16
|
224
|
+
[iin2.to_i, 'Master Card']
|
225
|
+
# {'IIN' => iin2.to_i, 'Brand Name' => 'Master Card'}
|
214
226
|
elsif iin1 == '1' && length == 15
|
215
227
|
[iin1.to_i, 'UATP']
|
216
|
-
# {'IIN' => iin1.to_i, '
|
217
|
-
elsif (('506099'..'506198').include? (iin6)) || (('650002'..'650027').include? (iin6)) && (length == 16 || length == 19)
|
218
|
-
[iin6.to_i, 'Verve']
|
219
|
-
# {'IIN' => iin6.to_i, 'Company Name' => 'Verve'}
|
220
|
-
elsif (['4026', '4508', '4844', '4913', '4917'].include? (iin4)) && (length == 13 || length == 16)
|
221
|
-
[iin4.to_i, 'Visa Electron']
|
222
|
-
# {'IIN' => iin4.to_i, 'Company Name' => 'Visa Electron'}
|
223
|
-
elsif iin6 == '417500' && (length == 13 || length == 16)
|
224
|
-
[iin6.to_i, 'Visa Electron']
|
225
|
-
# {'IIN' => iin6.to_i, 'Company Name' => 'Visa Electron'}
|
228
|
+
# {'IIN' => iin1.to_i, 'Brand Name' => 'UATP'}
|
226
229
|
elsif iin1 == '4' && (length == 13 || length == 16)
|
227
230
|
[iin1.to_i, 'Visa']
|
228
|
-
# {'IIN' => iin1.to_i, '
|
229
|
-
elsif iin4 == '8699' && length == 15
|
230
|
-
[iin4.to_i, 'Voyager']
|
231
|
-
# {'IIN' => iin4.to_i, 'Company Name' => 'Voyager'}
|
231
|
+
# {'IIN' => iin1.to_i, 'Brand Name' => 'Visa'}
|
232
232
|
else
|
233
233
|
# return 0 as IIN Range and Unknown as brand name if card number is not determined
|
234
234
|
[0, 'Unknown']
|