Ruby
Learn how to install and configure our Ruby SDK to use Efí's APIs
Requests made to Efí's APIs using the Ruby SDK require the certificate generated in your Efí account in the .pem format.
Check here the step-by-step guide to convert your P12 certificate to PEM format.
Installation via RubyGems
Add this line to your application's Gemfile:
- Efí Pay
gem 'sdk_ruby_apis_efi'
And then run:
$ bundle
Or install it as:
- Efí Pay
$ gem install sdk_ruby_apis_efi
Installation via Git
Our SDK is also available in our Efí Github repository.
- Efí Pay
$ git clone https://github.com/efipay/sdk-ruby-apis-efi.git
Tested with
- Ruby
2.1.0 - Ruby
2.7.0 - Ruby
3.0.4
Basic Usage
- Efí Pay
require 'sdk_ruby_apis_efi'
require_relative "../../credentials"
options = {
client_id: CREDENTIALS::CLIENT_ID,
client_secret: CREDENTIALS::CLIENT_SECRET,
sandbox: CREDENTIALS::SANDBOX
}
body = {
items: [{
name: "Product 1",
value: 1000,
amount: 2
}],
shippings: [{
name: "Default Shipping Cost",
value: 100
}]
}
efipay = SdkRubyApisEfi.new(options)
puts efipay.create_charge(body: body)
Examples
You can run the examples inside the examples directory with:
$ ruby examples/create_charge.rb
Remember to set the correct credentials within examples/credentials.rb before running.
Tests
To run the tests, simply run rspec:
$rspec
Or use guard to monitor files and automatically run rspec:
$ guard -n false -c