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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2e3602c40ffd4cb6086114906d5f6b82e6b37df
4
- data.tar.gz: 43f1199a5d1cd94ab191007d01b2375729284fdf
3
+ metadata.gz: 0d89460e2223e34b79473b5d3b1854465c295bee
4
+ data.tar.gz: 9131605b327993952896511d9c73780f198a2697
5
5
  SHA512:
6
- metadata.gz: 2c2442ab8677d5f245c095a2326c09d8162dff52f727248938af2da4132d5d162ec6e45d62b2f3eba489a7d24ccd68a65fbca976b4a91c6fc936d9496e164069
7
- data.tar.gz: 1f0fea035b4025741cc2e9db5c9d1372faa98c00933176c574a869ba7e1a5829fe0d5a5825ff04bd3cdc5345808f2a19629bf1f7e262a402d57f18c73936a528
6
+ metadata.gz: 254d7b0953bf27b6f323b2df6c57e9821e5efdc2d86a6721bfa24b098c1fd88191817c50f7c58e9b861bf6202ab8444a421b41122609f2e694a36e23417adeef
7
+ data.tar.gz: 8f4b19f7da93a218da42cd9f86c1e0f285a91e0a797ca07730479f77ba7f14118a5fdbc01630abad8bca66ad3629fd43f2e4f7d9c0aa14fb360da09ea3f53446
data/.gitignore CHANGED
@@ -21,3 +21,5 @@ tmp
21
21
  *.a
22
22
  mkmf.log
23
23
  .DS_Store
24
+ .ruby-version
25
+ .ruby-gemset
data/.travis.yml CHANGED
@@ -7,3 +7,6 @@ rvm:
7
7
  - 2.1.2
8
8
 
9
9
  script: 'bundle exec rake'
10
+
11
+ before_install:
12
+ - gem update bundler
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
 
@@ -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]] || nil
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
- @data = nil
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
@@ -1,3 +1,3 @@
1
1
  module CreditCardBins
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -2,9 +2,10 @@ require "yaml"
2
2
  require "credit_card_bins/version"
3
3
  require "credit_card_bins/bin"
4
4
  require "credit_card_bins/string"
5
+ require "errors/not_found"
5
6
 
6
7
  class CreditCardBin < CreditCardBins::Bin
7
8
  def to_s
8
9
  self.name
9
10
  end
10
- end
11
+ end
data/lib/data/3/3607.yml CHANGED
@@ -69,3 +69,13 @@
69
69
  alpha_2: US
70
70
  alpha_3: USA
71
71
  name: United States
72
+ '360756':
73
+ bin: '360756'
74
+ brand: DINERS CLUB
75
+ type: CREDIT
76
+ category: ''
77
+ issuer: CITIBANK
78
+ country:
79
+ alpha_2: BR
80
+ alpha_3: BRA
81
+ name: Brazil
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: WACHOVIA BANK, N.A.
137
+ issuer: CJSC ALFA-BANK
138
138
  country:
139
- alpha_2: US
140
- alpha_3: USA
141
- name: United States
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: CREDIT
706
- category: GOLD PREMIUM
707
- issuer: BANCO COMERCIAL PORTUGUES, S.A.
705
+ type: DEBIT
706
+ category: PREPAID
707
+ issuer: PEOPLES TRUST COMPANY
708
708
  country:
709
- alpha_2: PT
710
- alpha_3: PRT
711
- name: Portugal
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: CREDIT
476
- category: CLASSIC
477
- issuer: FIRST USA BANK, N.A.
475
+ type: DEBIT
476
+ category: PREPAID
477
+ issuer: JPMORGAN CHASE BANK N.A.
478
478
  country:
479
- alpha_2: US
480
- alpha_3: USA
481
- name: United States
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: US
960
- alpha_3: USA
961
- name: United States
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: US
970
- alpha_3: USA
971
- name: United States
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: FIRST DATA GLOBAL SERVICES
315
+ type: CREDIT
316
+ category: PREPAID
317
+ issuer: ''
318
318
  country:
319
- alpha_2: GB
320
- alpha_3: GBR
321
- name: United Kingdom
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: US
220
- alpha_3: USA
221
- name: United States
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
@@ -933,7 +933,7 @@
933
933
  bin: '549693'
934
934
  brand: MASTERCARD
935
935
  type: ''
936
- category: ''
936
+ category: PREPAID
937
937
  issuer: ''
938
938
  country:
939
939
  alpha_2: CA
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: US
920
- alpha_3: USA
921
- name: United States
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: CREDIT
496
- category: STANDARD
497
- issuer: JORDAN AHLI BANK
495
+ type: DEBIT
496
+ category:
497
+ issuer: CJSC ALFA-BANK
498
498
  country:
499
- alpha_2: IQ
500
- alpha_3: IRQ
501
- name: Iraq
499
+ alpha_2: RU
500
+ alpha_3: RUS
501
+ name: Russian Federation
502
502
  '555950':
503
503
  bin: '555950'
504
504
  brand: MASTERCARD
@@ -0,0 +1,2 @@
1
+ class NotFound < StandardError
2
+ end
@@ -113,26 +113,14 @@ describe CreditCardBins do
113
113
 
114
114
  end
115
115
 
116
- describe "invalid attributes" do
117
-
118
- it "has a nil :data attribute when the number is empty" do
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.1
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: 2014-08-17 00:00:00.000000000 Z
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