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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/validator.rb +101 -101
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e12970371ef5fd0f6ed604f6a12a7701bf6431e9
4
- data.tar.gz: f4c6658151cf1b47173a19fff55add2104205af2
3
+ metadata.gz: 806b058d0bc2424570ab4a87293a62fe412831cc
4
+ data.tar.gz: df60a74e75ea4cc4cfd88aff50f710d9d1bf7dc1
5
5
  SHA512:
6
- metadata.gz: 6444b5fc29abb48e717822dc68c3112f8b3f4c24cccb541f21db33b51dbcf0d33179fa635e3e8e34a0fd5076db230959bc0498dcc88b97fc1141700973d1415b
7
- data.tar.gz: 59230fd2eeabb63ad331c5130bbde602074929a4542c42455b5526f65c0d059327861a80c8c54ce65f9f056bc3fc5b776a70ae5f844b51505fd4937a30e4fa8b
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
- if (['34', '37'].include? (iin2)) && length == 15
116
- [iin2.to_i, 'American Express']
117
- # {'IIN' => iin2.to_i, 'Company Name' => 'American Express'}
118
- elsif iin4 == '5610' && length == 16
119
- [iin4.to_i, 'Bankcard']
120
- # {'IIN' => iin4.to_i, 'Company Name' => 'Bankcard'}
121
- elsif (('560221'..'560225').include? (iin6)) && length == 16
122
- [iin6.to_i, 'Bankcard']
123
- # {'IIN' => iin6.to_i, 'Company Name' => 'Bankcard'}
124
- elsif iin4 == '5392' && length == 16
125
- [iin4.to_i, 'CARDGUARD']
126
- # {'IIN' => iin4.to_i, 'Company Name' => 'CARDGUARD EAD BG ILS'}
127
- elsif (['622', '624', '625', '626', '628'].include? (iin3)) && (length >= 16 && length <= 19)
128
- [iin3.to_i, 'China UnionPay']
129
- # {'IIN' => iin3.to_i, 'Company Name' => 'China UnionPay'}
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, 'Company Name' => 'Dankort'}
133
- elsif (('301'..'305').include? (iin3)) && length == 14
134
- [iin3.to_i, 'Diners Club Carte Blanche']
135
- # {'IIN' => iin3.to_i, 'Company Name' => 'Diners Club Carte Blanche'}
136
- elsif (['2014', '2149'].include? (iin4)) && length == 15
137
- [iin4.to_i, 'Diners Club Carte enRoute']
138
- # {'IIN' => iin4.to_i, 'Company Name' => 'Diners Club Carte enRoute'}
139
- elsif (['36', '38', '39'].include? (iin2)) && length == 14
140
- [iin2.to_i, 'Diners Club International']
141
- # {'IIN' => iin2.to_i, 'Company Name' => 'Diners Club International'}
142
- elsif iin3 == '309' && length == 14
143
- [iin3.to_i, 'Diners Club International']
144
- # {'IIN' => iin3.to_i, 'Company Name' => 'Diners Club International'}
145
- elsif iin2 == '65' && length == 16
146
- [iin2.to_i, 'Discover Card']
147
- # {'IIN' => iin2.to_i, 'Company Name' => 'Discover Card'}
148
- elsif (('644'..'649').include? (iin3)) && length == 16
149
- [iin3.to_i, 'Discover Card']
150
- # {'IIN' => iin3.to_i, 'Company Name' => 'Discover Card'}
151
- elsif iin4 == '6011' && length == 16
152
- [iin4.to_i, 'Discover Card']
153
- # {'IIN' => iin4.to_i, 'Company Name' => 'Discover Card'}
154
- elsif (('622126'..'622925').include? (iin6)) && length == 16
155
- [iin6.to_i, 'Discover Card']
156
- # {'IIN' => iin6.to_i, 'Company Name' => 'Discover Card'}
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, 'Company Name' => 'Hipercard'}
160
- elsif (('637'..'639').include? (iin3)) && length == 16
161
- [iin3.to_i, 'InstaPayment']
162
- # {'IIN' => iin3.to_i, 'Company Name' => 'InstaPayment'}
163
- elsif iin3 == '636' && (length >= 16 && length <= 19)
164
- [iin3.to_i, 'InterPayment']
165
- # {'IIN' => iin3.to_i, 'Company Name' => 'InterPayment'}
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, 'Company Name' => 'JCB'}
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, 'Company Name' => 'Maestro'}
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, 'Company Name' => 'Master Card'}
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, 'Company Name' => 'RuPay'}
202
- elsif (('6061'..'6069').include? (iin4)) && length == 16
203
- [iin4.to_i, 'RuPay']
204
- # {'IIN' => iin4.to_i, 'Company Name' => 'RuPay'}
205
- elsif (['6334', '6767'].include? (iin4)) && (length == 16 || length == 18 || length == 19)
206
- [iin4.to_i, 'Solo']
207
- # {'IIN' => iin4.to_i, 'Company Name' => 'Solo'}
208
- elsif (['4903', '4905', '4911', '4936', '6333', '6759'].include? (iin4)) && (length == 16 || length == 18 || length == 19)
209
- [iin4.to_i, 'Switch']
210
- # {'IIN' => iin4.to_i, 'Company Name' => 'Switch'}
211
- elsif (['633312', '633110', '633304', '633303', '633301', '633300'].include? (iin6)) && (length == 16 || length == 18 || length == 19)
212
- [iin6.to_i, 'Switch']
213
- # {'IIN' => iin6.to_i, 'Company Name' => 'Switch'}
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, 'Company Name' => 'UATP'}
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, 'Company Name' => 'Visa'}
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']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: credit_debit_card_number_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.09.7
4
+ version: 16.09.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ali Osm