credit_card_bins 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +3 -0
- data/README.md +9 -3
- data/lib/credit_card_bins/bin.rb +8 -4
- data/lib/credit_card_bins/version.rb +1 -1
- data/lib/credit_card_bins.rb +2 -1
- data/lib/data/3/3607.yml +10 -0
- data/lib/data/4/4261.yml +5 -5
- data/lib/data/4/4263.yml +6 -6
- data/lib/data/4/4408.yml +6 -6
- data/lib/data/4/4782.yml +12 -12
- data/lib/data/5/5314.yml +6 -6
- data/lib/data/5/5336.yml +4 -4
- data/lib/data/5/5496.yml +1 -1
- data/lib/data/5/5536.yml +5 -5
- data/lib/data/5/5559.yml +6 -6
- data/lib/errors/not_found.rb +2 -0
- data/spec/credit_card_bins_spec.rb +12 -17
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d89460e2223e34b79473b5d3b1854465c295bee
|
4
|
+
data.tar.gz: 9131605b327993952896511d9c73780f198a2697
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 254d7b0953bf27b6f323b2df6c57e9821e5efdc2d86a6721bfa24b098c1fd88191817c50f7c58e9b861bf6202ab8444a421b41122609f2e694a36e23417adeef
|
7
|
+
data.tar.gz: 8f4b19f7da93a218da42cd9f86c1e0f285a91e0a797ca07730479f77ba7f14118a5fdbc01630abad8bca66ad3629fd43f2e4f7d9c0aa14fb360da09ea3f53446
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
# CreditCardBins - A Credit Card IIN/BIN lookup Ruby gem.
|
2
2
|
|
3
3
|
[![Build Status](https://secure.travis-ci.org/hugolantaume/credit_card_bins.png?branch=master)](http://travis-ci.org/hugolantaume/credit_card_bins)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/credit_card_bins.svg)](http://badge.fury.io/rb/credit_card_bins)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/hugolantaume/credit_card_bins/badge.png?branch=master)](https://coveralls.io/r/hugolantaume/credit_card_bins?branch=master)
|
4
6
|
|
5
7
|
The Issuer Identification Number (IIN), previously known as Bank Identification Number (BIN) is the first six numbers of a credit card. These identify the institution that issued the card to the card holder and provide useful information about the card that can help make your payments flow smarter.
|
6
8
|
|
9
|
+
The database is located in lib/data and the gem does not use any third-party API.
|
10
|
+
|
11
|
+
|
7
12
|
## Installation
|
8
13
|
|
9
14
|
Add this line to your application's Gemfile:
|
@@ -38,22 +43,23 @@ Example using the CreditCardBin Class
|
|
38
43
|
|
39
44
|
number = "378282246310005"
|
40
45
|
bin = CreditCardBin.new(number)
|
41
|
-
|
46
|
+
|
42
47
|
bin.bin #"378282"
|
43
48
|
bin.brand #"AMERICAN EXPRESS"
|
44
49
|
bin.type #"CREDIT"
|
45
50
|
bin.category #"SMALL CORPORATE"
|
46
51
|
bin.issuer #"AMERICAN EXPRESS COMPANY"
|
47
52
|
bin.country #{"alpha_2"=>"US", "alpha_3"=>"USA", "name"=>"United States"}
|
48
|
-
|
53
|
+
|
49
54
|
bin.visa? #false
|
50
55
|
bin.amex? #true
|
51
56
|
bin.mastercard? #false
|
52
|
-
|
57
|
+
|
53
58
|
bin.debit? #false
|
54
59
|
bin.credit? #true
|
55
60
|
bin.prepaid? #false
|
56
61
|
|
62
|
+
When credicard number is not found, will be throws an exception `NotFound`.
|
57
63
|
|
58
64
|
## Contributing
|
59
65
|
|
data/lib/credit_card_bins/bin.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module CreditCardBins; end
|
2
2
|
|
3
3
|
class CreditCardBins::Bin
|
4
|
-
|
4
|
+
|
5
5
|
AttrReaders = [
|
6
6
|
:bin,
|
7
7
|
:brand,
|
@@ -20,9 +20,9 @@ class CreditCardBins::Bin
|
|
20
20
|
attr_reader :data
|
21
21
|
|
22
22
|
def initialize(number)
|
23
|
-
@data = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'data', number[0].to_s, number[0..3].to_s + '.yml' ))[number.to_s[0..5]]
|
23
|
+
@data = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'data', number[0].to_s, number[0..3].to_s + '.yml' ))[number.to_s[0..5]]
|
24
24
|
rescue
|
25
|
-
|
25
|
+
raise NotFound, "Bin #{number} not found"
|
26
26
|
end
|
27
27
|
|
28
28
|
def ==(other)
|
@@ -99,6 +99,10 @@ class CreditCardBins::Bin
|
|
99
99
|
@data["brand"] == "SOLO"
|
100
100
|
end
|
101
101
|
|
102
|
+
def diners_club?
|
103
|
+
@data["brand"] == "DINERS CLUB"
|
104
|
+
end
|
105
|
+
|
102
106
|
### Type
|
103
107
|
|
104
108
|
def debit?
|
@@ -112,4 +116,4 @@ class CreditCardBins::Bin
|
|
112
116
|
def prepaid?
|
113
117
|
@data["type"] == "PREPAID"
|
114
118
|
end
|
115
|
-
end
|
119
|
+
end
|
data/lib/credit_card_bins.rb
CHANGED
data/lib/data/3/3607.yml
CHANGED
data/lib/data/4/4261.yml
CHANGED
@@ -132,13 +132,13 @@
|
|
132
132
|
'426113':
|
133
133
|
bin: '426113'
|
134
134
|
brand: VISA
|
135
|
-
type: ''
|
135
|
+
type: 'DEBIT'
|
136
136
|
category: ''
|
137
|
-
issuer:
|
137
|
+
issuer: CJSC ALFA-BANK
|
138
138
|
country:
|
139
|
-
alpha_2:
|
140
|
-
alpha_3:
|
141
|
-
name:
|
139
|
+
alpha_2: RU
|
140
|
+
alpha_3: RUS
|
141
|
+
name: Russian Federation
|
142
142
|
'426114':
|
143
143
|
bin: '426114'
|
144
144
|
brand: VISA
|
data/lib/data/4/4263.yml
CHANGED
@@ -702,13 +702,13 @@
|
|
702
702
|
'426370':
|
703
703
|
bin: '426370'
|
704
704
|
brand: VISA
|
705
|
-
type:
|
706
|
-
category:
|
707
|
-
issuer:
|
705
|
+
type: DEBIT
|
706
|
+
category: PREPAID
|
707
|
+
issuer: PEOPLES TRUST COMPANY
|
708
708
|
country:
|
709
|
-
alpha_2:
|
710
|
-
alpha_3:
|
711
|
-
name:
|
709
|
+
alpha_2: CA
|
710
|
+
alpha_3: CAN
|
711
|
+
name: Canada
|
712
712
|
'426371':
|
713
713
|
bin: '426371'
|
714
714
|
brand: VISA
|
data/lib/data/4/4408.yml
CHANGED
@@ -472,13 +472,13 @@
|
|
472
472
|
'440847':
|
473
473
|
bin: '440847'
|
474
474
|
brand: VISA
|
475
|
-
type:
|
476
|
-
category:
|
477
|
-
issuer:
|
475
|
+
type: DEBIT
|
476
|
+
category: PREPAID
|
477
|
+
issuer: JPMORGAN CHASE BANK N.A.
|
478
478
|
country:
|
479
|
-
alpha_2:
|
480
|
-
alpha_3:
|
481
|
-
name:
|
479
|
+
alpha_2: CA
|
480
|
+
alpha_3: CAN
|
481
|
+
name: Canada
|
482
482
|
'440848':
|
483
483
|
bin: '440848'
|
484
484
|
brand: VISA
|
data/lib/data/4/4782.yml
CHANGED
@@ -952,23 +952,23 @@
|
|
952
952
|
'478295':
|
953
953
|
bin: '478295'
|
954
954
|
brand: VISA
|
955
|
-
type:
|
956
|
-
category:
|
957
|
-
issuer:
|
955
|
+
type: DEBIT
|
956
|
+
category: Platinum
|
957
|
+
issuer: SAUDI INVESTMENT BANK
|
958
958
|
country:
|
959
|
-
alpha_2:
|
960
|
-
alpha_3:
|
961
|
-
name:
|
959
|
+
alpha_2: SA
|
960
|
+
alpha_3: SAU
|
961
|
+
name: Saudi Arabia
|
962
962
|
'478296':
|
963
963
|
bin: '478296'
|
964
964
|
brand: VISA
|
965
|
-
type:
|
966
|
-
category:
|
967
|
-
issuer:
|
965
|
+
type: Traditional
|
966
|
+
category: DEBIT
|
967
|
+
issuer: SAUDI INVESTMENT BANK
|
968
968
|
country:
|
969
|
-
alpha_2:
|
970
|
-
alpha_3:
|
971
|
-
name:
|
969
|
+
alpha_2: SA
|
970
|
+
alpha_3: SAU
|
971
|
+
name: Saudi Arabia
|
972
972
|
'478297':
|
973
973
|
bin: '478297'
|
974
974
|
brand: VISA
|
data/lib/data/5/5314.yml
CHANGED
@@ -312,13 +312,13 @@
|
|
312
312
|
'531431':
|
313
313
|
bin: '531431'
|
314
314
|
brand: MASTERCARD
|
315
|
-
type:
|
316
|
-
category:
|
317
|
-
issuer:
|
315
|
+
type: CREDIT
|
316
|
+
category: PREPAID
|
317
|
+
issuer: ''
|
318
318
|
country:
|
319
|
-
alpha_2:
|
320
|
-
alpha_3:
|
321
|
-
name:
|
319
|
+
alpha_2: CA
|
320
|
+
alpha_3: CAN
|
321
|
+
name: Canada
|
322
322
|
'531432':
|
323
323
|
bin: '531432'
|
324
324
|
brand: MASTERCARD
|
data/lib/data/5/5336.yml
CHANGED
@@ -213,12 +213,12 @@
|
|
213
213
|
bin: '533621'
|
214
214
|
brand: MASTERCARD
|
215
215
|
type: ''
|
216
|
-
category:
|
216
|
+
category: PREPAID
|
217
217
|
issuer: ''
|
218
218
|
country:
|
219
|
-
alpha_2:
|
220
|
-
alpha_3:
|
221
|
-
name:
|
219
|
+
alpha_2: CA
|
220
|
+
alpha_3: CAN
|
221
|
+
name: Canada
|
222
222
|
'533622':
|
223
223
|
bin: '533622'
|
224
224
|
brand: MASTERCARD
|
data/lib/data/5/5496.yml
CHANGED
data/lib/data/5/5536.yml
CHANGED
@@ -912,13 +912,13 @@
|
|
912
912
|
'553691':
|
913
913
|
bin: '553691'
|
914
914
|
brand: MASTERCARD
|
915
|
-
type: ''
|
915
|
+
type: 'DEBIT'
|
916
916
|
category: ''
|
917
|
-
issuer: ''
|
917
|
+
issuer: 'TINKOFF CREDIT SYSTEMS BANK (CJSC)'
|
918
918
|
country:
|
919
|
-
alpha_2:
|
920
|
-
alpha_3:
|
921
|
-
name:
|
919
|
+
alpha_2: RU
|
920
|
+
alpha_3: RUS
|
921
|
+
name: Russian Federation
|
922
922
|
'553692':
|
923
923
|
bin: '553692'
|
924
924
|
brand: MASTERCARD
|
data/lib/data/5/5559.yml
CHANGED
@@ -492,13 +492,13 @@
|
|
492
492
|
'555949':
|
493
493
|
bin: '555949'
|
494
494
|
brand: MASTERCARD
|
495
|
-
type:
|
496
|
-
category:
|
497
|
-
issuer:
|
495
|
+
type: DEBIT
|
496
|
+
category:
|
497
|
+
issuer: CJSC ALFA-BANK
|
498
498
|
country:
|
499
|
-
alpha_2:
|
500
|
-
alpha_3:
|
501
|
-
name:
|
499
|
+
alpha_2: RU
|
500
|
+
alpha_3: RUS
|
501
|
+
name: Russian Federation
|
502
502
|
'555950':
|
503
503
|
bin: '555950'
|
504
504
|
brand: MASTERCARD
|
@@ -113,26 +113,14 @@ describe CreditCardBins do
|
|
113
113
|
|
114
114
|
end
|
115
115
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
empty_number_bin = CreditCardBin.new("")
|
120
|
-
expect(empty_number_bin.data).to be_nil
|
121
|
-
end
|
122
|
-
|
123
|
-
it "has a nil :data attribute when the number is too short" do
|
124
|
-
too_short_number_bin = CreditCardBin.new("1234")
|
125
|
-
expect(too_short_number_bin.data).to be_nil
|
126
|
-
end
|
127
|
-
|
128
|
-
it "has a nil :data attribute when the number is not found in the database" do
|
129
|
-
not_found_number_bin = CreditCardBin.new("0010000")
|
130
|
-
expect(not_found_number_bin.data).to be_nil
|
116
|
+
context "when bin not found" do
|
117
|
+
it "should raise error NotFound" do
|
118
|
+
expect { CreditCardBin.new("09123") }.to raise_error(NotFound, /Bin \d+ not found/)
|
131
119
|
end
|
132
120
|
end
|
133
121
|
|
134
122
|
describe "methods" do
|
135
|
-
|
123
|
+
|
136
124
|
it "include a private_label? query" do
|
137
125
|
valid_private_label_bin = CreditCardBin.new("019627")
|
138
126
|
expect(valid_private_label_bin.private_label?).to eq(true)
|
@@ -217,6 +205,13 @@ describe CreditCardBins do
|
|
217
205
|
expect(invalid_solo_bin.solo?).to eq(false)
|
218
206
|
end
|
219
207
|
|
208
|
+
it "include a diners club? query" do
|
209
|
+
valid_diners_club_bin = CreditCardBin.new("360756")
|
210
|
+
expect(valid_diners_club_bin.diners_club?).to eq(true)
|
211
|
+
valid_diners_club_bin = CreditCardBin.new("497040")
|
212
|
+
expect(valid_diners_club_bin.diners_club?).to eq(false)
|
213
|
+
end
|
214
|
+
|
220
215
|
|
221
216
|
it "include a credit? query" do
|
222
217
|
valid_credit_bin = CreditCardBin.new("180000")
|
@@ -278,4 +273,4 @@ describe CreditCardBins do
|
|
278
273
|
expect(bin_country).to eq(c_country)
|
279
274
|
end
|
280
275
|
end
|
281
|
-
end
|
276
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: credit_card_bins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hugo Lantaume
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -2849,6 +2849,7 @@ files:
|
|
2849
2849
|
- lib/data/9/9988.yml
|
2850
2850
|
- lib/data/9/9998.yml
|
2851
2851
|
- lib/data/9/9999.yml
|
2852
|
+
- lib/errors/not_found.rb
|
2852
2853
|
- spec/credit_card_bins_spec.rb
|
2853
2854
|
- spec/spec_helper.rb
|
2854
2855
|
homepage: http://github.com/hugolantaume/credit_card_bins
|