Ruby
Introduction
The Mangopay Ruby SDK makes working with the Mangopay API easier in a Ruby environment.
The SDK package is available on RubyGems: mangopay4-ruby-sdk
Caution – Use only the mangopay4 package (late Nov 2025)
Please ensure you use only the package with mangopay4 in the name (this is the package name and has no connection with the SDK version number).
Any other package must not be used. You need to update your package manually.
Since November 25, 2025, Mangopay’s official SDKs are no longer accessible on GitHub (with the exception of PHP for publication reasons).
Prerequisites
To run the Mangopay Ruby SDK, you’ll need:
- A
ClientIdand 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
The configuration object of the SDK supports all the following properties:
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
Error handling
The SDK provides the MangoPay::ResponseError exception object to wrap HTTP errors returned by the API.
You can wrap your function in a begin…rescue block to catch errors, and the ex.details hash to create specific logic, for example: