GitHunt
HU

hugolantaume/credit_card_bins

Simple Credit Card IIN/BIN lookup Ruby gem.

CreditCardBins - A Credit Card IIN/BIN lookup Ruby gem.

Build Status
Gem Version
Coverage Status

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.

The database is located in lib/data and the gem does not use any third-party API.

Installation

Add this line to your application's Gemfile:

gem 'credit_card_bins'

And then execute:

$ bundle

Or install it yourself as:

$ gem install credit_card_bins

How to use CreditCardBins

CreditCardBins is designed to make it easy to access a credit card's brand, issuer, type and more.

Examples using string monkey patch

require 'credit_card_bins'

'497040'.credit_card_bin_brand #"VISA"
'497040'.credit_card_bin_type #"CREDIT"
'497040'.credit_card_bin_category #"CLASSIC"
'497040'.credit_card_bin_issuer #"LA BANQUE POSTALE"
'497040'.credit_card_bin_country #{"alpha_2"=>"FR", "alpha_3"=>"FRA", "name"=>"France"}

Example using the CreditCardBin Class

require 'credit_card_bins'

number = "378282246310005"
bin = CreditCardBin.new(number)

bin.bin #"378282"
bin.brand #"AMERICAN EXPRESS"
bin.type #"CREDIT"
bin.category #"SMALL CORPORATE"
bin.issuer #"AMERICAN EXPRESS COMPANY"
bin.country #{"alpha_2"=>"US", "alpha_3"=>"USA", "name"=>"United States"}

bin.visa? #false
bin.amex? #true
bin.mastercard? #false

bin.debit? #false
bin.credit? #true
bin.prepaid? #false

When credicard number is not found, will be throws an exception NotFound.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Languages

Ruby100.0%

Contributors

MIT License
Created August 17, 2014
Updated February 14, 2026
hugolantaume/credit_card_bins | GitHunt