Introduction
The Mangopay Ruby SDK makes working with the Mangopay API easier in a Ruby environment. This SDK is open-source and available on GitHub. Mangopay Ruby SDKPrerequisitesTo run the Mangopay Ruby SDK, you’ll need:
- A
ClientId
and an API key – if you don’t have these, contact Sales to get access to the Mangopay Dashboard - Ruby 1.9.2 or higher (tested from 1.9.2 up to 3.4.4)
Getting started
- Install the SDK
- Initialize and configure the SDK
Key | Type | Default value | Description |
---|---|---|---|
preproduction | boolean | false | Defines whether the SDK calls the Production or Sandbox endpoints. |
client_id | string | None | Your Mangopay ClientId – can be found in the Dashboard. |
client_apiKey | string | None | Your Mangopay API key – can be found in the Dashboard. |
http_timeout | int milliseconds | 30 | Specifies the amount of time until request failure because a chunk of data cannot be read. |
http_open_timeout | int milliseconds | 30 | Specifies the amount of time until request failure because a connection cannot be made. |
log_file | string | None | Enables logging. Results and responses are filtered so that confidential data is not saved in the log. |
uk_header_flag | boolean | false | Platforms that have contracted with Mangopay’s UK entity (MANGOPAY U.K. LIMITED) must include the following header in all requests. If you’re using an SDK, you need to set it to true . |
SDK usage
All endpoints are documented with the related Ruby SDK method throughout the Mangopay documentation. You should adjust the code examples provided for your usage.Multi configurations
The Ruby SDK offers the option to create multiple configuration objects tailored to your specific needs:add_config
method to add the new configuration:
get_config
and apply_configuration
methods:
Pagination
For endpoints that support pagination, you can use an object containing thepage
and per_page
keys.
As a result, the answer will be paginated, and the total number of items and the total number of pages will be provided.
Pagination example
Filtering
For endpoints that support filtering, you can use an object containing the filtering parameters.Usage example
Error handling
As an alternative to logging, you can use the following example to surface errors returned by the Ruby SDK within your app.Error handling example
Rate limiting
Along with each request, the rate limiting headers are automatically updated in the MangoPay object:- X-RateLimit-Limit
- X-RateLimit-Remaining
- X-RateLimit-Reset
Rate limiting example