Project

ibancom

0.0
The project is in a healthy, maintained state
Ruby client for iban.com APIs
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 2.14.3, < 3
 Project Readme

Ibancom

Ruby client for iban.com APIs (cf. https://www.iban.com/developers)

Run bin/console for an interactive prompt to experiment with the code.

Installation

Add this line to your application's Gemfile:

gem 'ibancom'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install ibancom

Supported APIs

This gem provides support for the following APIs:

  • Validation API v4
  • Sortware API v4

Usage

The first step for using this gem is to instantiate the client:

client = Ibancom::Client.new(apikey: "YOUR_API_KEY")

HTTP logging is enabled by default through Faraday::Response::Logger. You can replace that middleware and pass extra options to it:

client = Ibancom::Client.new(
  apikey: "YOUR_API_KEY",
  logger_middleware: CustomMiddleware,
  logger_options: { log_level: :debug }
)

logger_options are merged over { headers: true, bodies: true }. The middleware is initialized as Middleware.new(app, nil, options) and receives the existing password filter block. Set logger_enabled: false to skip logging.

Once you have an authenticated client, you can validate any IBAN easily by using the validations service:

# Request an IBAN validation
iban = client.validations.validate("ES8800758353964664433159")
iban.valid? # true

# What is the bank/branch associated to this account?
bank = iban.bank # <Ibancom::Resources::IBAN::Bank:0x00007f384a4b80f0 ...
bank.bank        # "BANCO SANTANDER, S.A."
bank.bic         # "BSCHESMMXXX"
bank.account     # "4664433159"
bank.bank_code   # "0075"
bank.branch_code # "8353"
bank.address     # "JUAN IGNACIO LUCA DE TENA 9-11"
bank.city        # "MADRID"
bank.state       # nil
bank.zip         # "28027"
bank.phone       # "0915207000"
bank.country     # "Spain"
bank.country_iso # "ES"

# What SEPA schemes does it support?
iban.supported_schemes
#[#<Ibancom::Resources::IBAN::Scheme:0x00007f384f37a710 @code=:SCT, @response=nil, @supported="YES">,
# #<Ibancom::Resources::IBAN::Scheme:0x00007f384f37a030 @code=:SCI, @response=nil, @supported="YES">,
# #<Ibancom::Resources::IBAN::Scheme:0x00007f384f379e50 @code=:SDD, @response=nil, @supported="YES">,
# #<Ibancom::Resources::IBAN::Scheme:0x00007f384f379d10 @code=:COR1, @response=nil, @supported="YES">,
# #<Ibancom::Resources::IBAN::Scheme:0x00007f384f379ba8 @code=:B2B, @response=nil, @supported="YES">]

# Does the IBAN supports instant transfers?
iban.supported_scheme?(:SCI) # true

When the IBAN is not valid the failed checks are available for inspection:

iban = client.validations.validate("ES12")
iban.valid? # false
iban.failed_checks
#[#<Ibancom::Resources::IBAN::Check:0x00007f384a576eb0 @code="202", @message="IBAN Check digit not correct", @response=nil, @type=:iban>,
# #<Ibancom::Resources::IBAN::Check:0x00007f384a576de8 @code="205", @message="IBAN structure is not correct", @response=nil, @type=:structure>,
# #<Ibancom::Resources::IBAN::Check:0x00007f384a576cf8 @code="203", @message="IBAN Length is not correct. Spain IBAN must be 24 characters long.", @response=nil, @type=:length>]

You can also validate United Kingdom Sort Code and Account Numbers:

scan = client.validations.validate_scan("200415", "38290008")
scan.valid? # true

# What is the bank/branch associated to this account?
bank = scan.bank # <Ibancom::Resources::SCAN::Bank:0x0000000107c0fc80 ...
bank.bank        # "BARCLAYS BANK UK PLC"
bank.bic         # "BUKBGB22XXX"
bank.branch      # "BARCLAYBANK B'CARD N'PTON"
bank.address     # "Dept AC Barclaycard House "
bank.city        # "Northampton"
bank.zip         # "NN4 7SG"
bank.phone       # "01604 234234"
bank.country     # "GB"

# What payment schemes does it support?
scan.supported_schemes
#[#<Ibancom::Resources::SCAN::Scheme:0x0000000107c0df70 @code=:FPS_PAYMENTS, @response=nil, @supported="YES">,
# #<Ibancom::Resources::SCAN::Scheme:0x0000000107c0def8 @code=:CHAPS, @response=nil, @supported="YES">,
# #<Ibancom::Resources::SCAN::Scheme:0x0000000107c0de80 @code=:BACS, @response=nil, @supported="YES">,
# #<Ibancom::Resources::SCAN::Scheme:0x0000000107c0de08 @code=:CCC_PAYMENTS, @response=nil, @supported="YES">]

# Does the SCAN supports faster payments?
scan.supported_scheme?(:FPS_PAYMENTS) # true

In the same way as with the IBAN, when the SCAN is not valid the failed checks are available for inspection:

scan = client.validations.validate_scan("000001", "00000002")
scan.valid? # false
scan.failed_checks
#[#<Ibancom::Resources::SCAN::Check:0x00000001088debf0 @code="202", @message="Sort Code not found in bank directory",
# @response=nil, @type=:length>]

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bundle exec rake to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install.

Releasing

Anyone with write access can release:

  1. Open a PR titled Bump to vX.Y.Z that:

    • bumps the version in lib/ibancom/version.rb and in Gemfile.lock (bundle install);
    • moves the entries under ## [Unreleased] in CHANGELOG.md into a new ## [X.Y.Z] - YYYY-MM-DD section, following Keep a Changelog.

    Merge it once CI passes.

  2. Tag the merge commit on main and push the tag:

    git switch main && git pull
    git tag -m vX.Y.Z vX.Y.Z
    git push origin vX.Y.Z

The tag triggers release.yml, which runs CI, fails unless the tag is on main and CHANGELOG.md has a section for the version, and publishes the gem to rubygems.org through trusted publishing with a Sigstore attestation. No API key is involved.

If the publish job fails, fix the cause and re-run the failed job; the tag stays as it is.

Once published, create a GitHub release for the tag with the version's changelog section as notes.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/devengoapp/ibancom-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open-source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the PFS project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the code of conduct.