Ruby
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 SDKPrerequisites
To 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) installed
Note - Mangopay SDK compatibility
The Ruby SDK is only compatible with the v2.01 version of the Mangopay API.
Getting started
- Install the SDK
- Initialize and configure the SDK
The configuration object of the SDK supports all the following properties:
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:
Once configured, you can the use the add_config
method to add the new configuration:
When you need to use a specific configuration, you can retrieve the needed configuration by using the get_config
and apply_configuration
methods:
Pagination
For endpoints that support pagination, you can use an object containing the page
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.
Filtering
For endpoints that support filtering, you can use an object containing the filtering parameters.
Error handling
As an alternative to logging, you can use the following example to surface errors returned by the Ruby SDK within your app.
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
Report an issue
Found a problem with the SDK? Create an issue on GitHub:
Report an issue →