Java
Introduction
The Mangopay Java SDK makes working with the Mangopay API easier in a Java environment. This SDK is open-source and available on GitHub.
Mangopay Java SDK →Prerequisites
To run the Mangopay Java 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 - Java 7.0+
- Your preferred build automation tools: Maven or Gradle
Getting started
1. Install the Mangopay package
The SDK is published as an artifact on Mangopay’s Maven Central Repository and can be used with Gradle or Maven.
Installation with Gradle
Add the following to your build.gradle file:
Installation with Maven
Add the Mangopay dependency to your pom.xml file:
2. Initialize and configure the SDK
The configuration object of the SDK supports all the following properties:
Key | Type | Default value | Description |
---|---|---|---|
setClientId | string | None | Your Mangopay ClientId – can be found in the Dashboard. |
setClientPassword | string | None | Your Mangopay API key – can be found in the Dashboard. |
setBaseUrl | string | https://api.sandbox.mangopay.com/v2.01/ | The API sandbox URL. Set to the sandbox environment by default. To enable production environment, set it to https://api.mangopay.com |
setConnectTimeout | integer | 60000 | Time to wait in milliseconds while trying to establish a connection before terminating the attempt and generating an error. |
setReadTimeout | integer | 60000 | Time to wait in milliseconds to receive a response before terminating the attempt and generating an error. |
setDebugMode | boolean | false | Activates the debug mode. Recommended only in Sandbox. |
setUkHeaderFlag | 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
In the Mangopay documentation, you’ll find detailed information of all endpoints paired with its corresponding Java SDK method implementation example. Be sure to customize the provided code to suit your specific requirements.
Idempotency support
To make a request with idempotency support, add idempotencyKey
parameter to your function.
For more information, see the Idempotency article.
In order to retrieve the request made using this idempotency:
Pagination and filtering
For endpoints that support pagination and filtering, you can use the Pagination
and Sorting
objects.
In the Pagination
object, you need to specify the page and items per page to return.
In the Sorting
object, you need to use the addField()
method to specify the sort direction.
As a result, the answer will be paginated, and the total number of items and the total number of pages will be provided. For example, with the List all Users endpoint:
Rate limiting status
Rate limiting in Mangopay restricts the frequency of API requests a client can make over a defined period, automatically updating the limit with each request and blocking additional requests if the limit is exceeded until it resets. For more information, see the rate limiting article.
Unit tests
All JUnit tests are placed under the tests directory.
Report an issue
Found a problem with the SDK? Create an issue on GitHub:
Report an issue →