Skip to main content

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).
PrerequisitesTo 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

  1. Install the SDK
  1. Initialize and configure the SDK
The configuration object of the SDK supports all the following properties:
KeyTypeDefault valueDescription
preproduction booleanfalseDefines whether the SDK calls the Production or Sandbox endpoints.
client_idstringNoneYour Mangopay ClientId – can be found in the Dashboard.
client_apiKeystringNoneYour Mangopay API key – can be found in the Dashboard.
http_timeout int milliseconds30Specifies the amount of time until request failure because a chunk of data cannot be read.
http_open_timeoutint milliseconds30Specifies the amount of time until request failure because a connection cannot be made.
log_filestringNoneEnables logging. Results and responses are filtered so that confidential data is not saved in the log.

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.
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

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: