Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Espago gem

Build Status Gem Version Code Climate Test Coverage

Installing Espago gem

gem install espago

or just add it to your Gemfile if you are running a Rails project


After registering at configure your app with the security credentials. More information about configuration of merchant account you can find in our documentation

The most standard way of configuring Espago is to do it globally on the Espago class.

Espago.app_id = 'your-espago-app-id'
Espago.app_password = 'your-espago-secret'
Espago.public_key = 'your-espago-key'
Espago.production = false #sets Espago enviroment to sandbox
Espago.api_version = 3

Sending request

There are two possible ways of sending requests by using Espago gem. The first possibility is to call everytime send_request() function with proper path, HTTP method and parameters.

Espago.send_request path, request_type, [parameters]

Here it is an example of using this way to create new client (read how to created token_id at :

Espago.send_request :clients, :post, {description: "Jan Kowalski", email: "", card: 'token_id'}

The second possible way to sending requests by Espago gem is to call the proper path on Espago object, using specific HTTP method and setting chosen parameteres.

Espago.path request_type, [parameters]

Below, it is an example of using this possibility to create new client:

Espago.clients :post, {description: "Jan Kowalski", email: "", card: 'token_id'}

Getting response

Every returned object includes informations about header and body of response.

For example for request:

client = Espago.clients :post, {description: "Jan Kowalski", email: "", card: 'token_id'}

Espago returns an special response object:

    "description"=>"Jan Kowalski",

To get response status code you should use "status" method. For example


returns "201" code.

To get body of response you should use "body" method. For example


can return hash with client details:

  "description"=>"Jan Kowalski",

Now if you want get customer's e-mail(or anoher field in 1st level of response) this short code should execute operation:
=> ""

=> {"company"=>"VI", "last4"=>"4242", "year"=>2019, "month"=>3, "first_name"=>"Jan", "last_name"=>"Kowalski", "authorized"=>nil, "created_at"=>1381834598}

All possible paths (resources)

ParameterDescriptionDocumentation link
tokensspecial id for credit card
clientsclients data
chargescredit payments
plansplans for recurring payments
subscriptionsrecurring payments for client according to the created plan
invoicessingle recurring payment
line_itemselement of every invoice