CreditCardInfo
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.
Uses two data providers: * First bincodes.com API (require registration and api key). * Second 'credit_card_bins' gem data.
Installation
Add this line to your application's Gemfile:
gem 'credit_card_info'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install credit_card_info
Configuration
CreditCardInfo::Config.configure do |config|
config.bincodes.api_key = "your_api_key"
config.bincodes.api_url = "https://api.bincodes.com"
# class for make HttpRequests
config.bincodes.http_klass = Net::HTTP
# set timeout for api request (10 by default)
config.bincodes.timeout = 10
# set cache provider class, Rails.cache by default when using in Rails application
config.cache.provider = Rails.cache
# set cache keys lifeitime, default is 31 day
config.cache.ttl = 2678400
# set cache keys prefix, result key will be prefix:bin
config.cache.key_prefix = "ccinfo"
# also you can use custom logger instance, default is Rails.logger for Rails apps, and stdout for others
config.logger = Logger.new($stdout)
end
Usage
You just need make call:
bin = '515735'
CreditCardInfo.fetch(bin)
# {
# bin: "515735",
# bank: "CITIBANK, N.A.",
# card: "MASTERCARD",
# type: "CREDIT",
# level: "WORLD CARD",
# country: "United States",
# countrycode: "US"
# }
By default that call will be search firstly via bincodes.com, and if find nothing will search via credit_card_bins gem.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request