The official Ruby library for integrating with the Onfido API.
Documentation can be found at https://documentation.onfido.com.
This version uses Onfido API v3.6. Refer to our API versioning guide for details of which client library versions use which versions of the API.
gem onfido, '~> 2.0.1'
Configure with your API token, region and optional timeout (default value is 30):
require onfido
Onfido.configure do |config|
config.api_token = ENV["ONFIDO_API_TOKEN"]
config.region = config.region[:EU]
config.timeout = 30
end
onfido_api = Onfido::DefaultApi.new
All resources share the same interface when making API calls. Use .create
to create a resource, .find
to find one, and .all
to fetch all resources.
applicant = onfido_api.create_applicant(
first_name: 'Test',
last_name: 'Applicant'
)
Documentation and code examples can be found at https://documentation.onfido.com
All errors are wrapped by ApiError
coming from FaradayExpection:
Connection timed out
is raised in case ofFaraday::TimeoutError
Connection failed
is raised in case ofFaraday::ConnectionFailed
All errors provide the response_code
, response_body
, json_body
, type
and fields
of the error.
def create_applicant
onfido_api.create_applicant(params)
rescue Faraday::ConnectionFailed => e
e.type # => 'validation_error'
e.fields # => { "email": { "messages": ["invalid format"] } }
e.response_code # => '422'
end
Webhook events payload needs to be verified before it can be accessed. Library allows to easily decode the payload and verify its signature before returning it as an object for user convenience:
require 'onfido/webhook_event_verifier'
def webhook_verifier()
verifier = Onfido::WebhookEventVerifier.new("_ABC123abc...3ABC123_")
signature = "a0...760e"
event = verifier.read_payload('{"payload":{"r...3"}}', signature)
rescue Onfido::OnfidoInvalidSignatureError => e
e.type
e.fields
e.response_code
end
This library is automatically generated using OpenAPI Generator - version: 7.5.0; therefore all the contributions, except tests files, should target Onfido OpenAPI specification repository instead of this repository.
For contributions to the tests instead, please follow the steps below:
- Fork repository
- Create your feature branch (
git checkout -b my-new-feature
) - Make your changes
- Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
More documentation and code examples can be found at https://documentation.onfido.com.
Should you encounter any technical issues during integration, please contact Onfido's Customer Support team via the Customer Experience Portal which also includes support documentation.