PHP

Introduction

The Mangopay PHP SDK makes working with the Mangopay API easier in a PHP environment.

The SDK package is published on Packagist and GitHub: mangopay4-php-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 PHP 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
  • PHP 5.6 (or higher)
  • cURL
  • OpenSSL
  • psr/log 1.0
  • Composer (optional but recommended for handling dependencies)

Getting started

1. Install the Mangopay package

Installation with Composer

  1. Install the Mangopay package
$composer require mangopay4/php-sdk
  1. Add the autoloader in your project
1require_once 'vendor/autoload.php';

Installation without Composer

  1. Download the Mangopay package

Go to the Releases page and download the SourceCode.zip asset from the most recent release.

2. Uncompress the SourceCode.zip file and move it to your project folder

  1. Include the autoloader in your project
1require_once 'mangopay4-php-sdk-[release number]/MangoPay/Autoload.php';

2. Initialize and configure the SDK

1require_once 'vendor/autoload.php';
2
3use MangoPay\MangoPayApi;
4use MangoPay\Libraries\ResponseException as MGPResponseException;
5use MangoPay\Libraries\Exception as MGPException;
6
7$api = new MangoPayApi();
8
9$api->Config->ClientId = 'your-client-id';
10$api->Config->ClientPassword = 'your-api-key';
11$api->Config->TemporaryFolder = 'your-temporary-folder-path';

The configuration object of the SDK supports all the following properties:

KeyTypeDefault valueDescription
ClientIdstringNoneYour Mangopay ClientId – can be found in the Dashboard.
ClientPasswordstringNoneYour Mangopay API key – can be found in the Dashboard.
BaseUrlstringhttps://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
TemporaryFolderstringNonePath to the folder where the temporary file is created.
CertificatesFilePath stringNonePath to the file holding one or more SSL certificates to verify the peer with. There is no cURL verification of the certificates when it’s set to null.
DebugModebooleantrueFor internal usage only. Logs all request and response data by default. To disable this mode, set it to false.
LogClassstringMangoPay\Libraries\LogsSet the logging class if DebugMode is enabled.
CurlConnectionTimeoutinteger30cURL connection timeout in seconds.
CurlResponseTimeoutinteger30cURL reset timeout in seconds.
HostProxystringNoneThe HTTP proxy to tunnel requests through.
UserPasswordProxystringNoneUsername and password formatted as [username]:[password] to use for the connection to the proxy.

SDK usage

In the Mangopay documentation, you’ll find detailed information of all endpoints paired with its corresponding PHP 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.

Call - Create user with idempotency key
1<?php
2 require_once 'vendor/autoload.php';
3
4 use MangoPay\MangoPayApi;
5 use MangoPay\Libraries\ResponseException as MGPResponseException;
6 use MangoPay\Libraries\Exception as MGPException;
7
8 $api = new MangoPayApi();
9
10 $api->Config->ClientId = 'your-client-id';
11 $api->Config->ClientPassword ='your-api-key';
12 $api->Config->TemporaryFolder = 'your-temporary-folder-path';
13
14 try {
15 $user = new \MangoPay\UserNatural();
16
17 $user->FirstName = 'Deborah';
18 $user->LastName = 'Smith';
19 $user->Email = "debbie.smith@example.com";
20
21 $user->Address = new \MangoPay\Address();
22 $user->Address->AddressLine1 = 'Rue des plantes';
23 $user->Address->AddressLine2 = 'Building A';
24 $user->Address->City = 'Paris';
25 $user->Address->Country = 'FR';
26 $user->Address->PostalCode = '75000';
27 $user->Address->Region = 'IDF';
28 $user->Tag = 'Created using the Mangopay PHP SDK';
29
30 $user->TermsAndConditionsAccepted = true;
31
32 $idempotencyKey = "fk7urhkW45kpTHf445608d";
33
34 $response = $api->Users->Create($user, $idempotencyKey);
35
36 print_r($response);
37
38 } catch(MGPResponseException $e) {
39 print_r($e);
40 } catch(MGPException $e) {
41 print_r($e);
42 }

In order to retrieve the request made using the idempotency key:

Call - View API Response
1<?php
2 require_once 'vendor/autoload.php';
3
4 use MangoPay\MangoPayApi;
5 use MangoPay\Libraries\ResponseException as MGPResponseException;
6 use MangoPay\Libraries\Exception as MGPException;
7
8 $api = new MangoPayApi();
9
10 $api->Config->ClientId = 'your-client-id';
11 $api->Config->ClientPassword = 'your-api-key';
12 $api->Config->TemporaryFolder = 'your-temporary-folder-path';
13
14 try {
15 $user = new \MangoPay\UserNatural();
16
17 $idempotencyKey = "fk7urhkW45kpTHf445608d";
18
19 $response = $api->Responses->Get($idempotencyKey);
20
21 print_r($response);
22
23 } catch(MGPResponseException $e) {
24 print_r($e);
25 } catch(MGPException $e) {
26 print_r($e);
27 }
Output
1 (
2 [StatusCode] => 200
3 [ContentLength] => 719
4 [ContentType] => application/json; charset=utf-8
5 [Date] => Mon, 25 Mar 2024 16:01:50 GMT
6 [RequestURL] => https://api.sandbox.mangopay.com/v2.01/your-client-id/users/natural
7 [Resource] => MangoPay\UserNatural Object
8 (
9 [Id] => user_m_01HSV5HEVH0RG33SY72W8GXM99
10 [Tag] => Created using the Mangopay PHP SDK
11 [CreationDate] => 1711382510
12 [PersonType] => NATURAL
13 [Email] => debbie.smith@example.com
14 [KYCLevel] => LIGHT
15 [TermsAndConditionsAccepted] => 1
16 [TermsAndConditionsAcceptedDate] => 1711382510
17 [UserCategory] => PAYER
18 [FirstName] => Deborah
19 [LastName] => Smith
20 [Address] => MangoPay\Address Object
21 (
22 [AddressLine1] => Rue des plantes
23 [AddressLine2] => Building A
24 [City] => Paris
25 [Region] => IDF
26 [PostalCode] => 75000
27 [Country] => FR
28 )
29
30 [Birthday] =>
31 [Nationality] =>
32 [CountryOfResidence] =>
33 [Occupation] =>
34 [IncomeRange] =>
35 [ProofOfIdentity] =>
36 [ProofOfAddress] =>
37 [Capacity] => NORMAL
38 )
39
40 )

Pagination and filtering

For endpoints that support pagination and filtering, you can use the Pagination() and Sorting() methods to specify these options:

1<?php
2 require_once 'vendor/autoload.php';
3
4 use MangoPay\MangoPayApi;
5 use MangoPay\Libraries\ResponseException as MGPResponseException;
6 use MangoPay\Libraries\Exception as MGPException;
7 use MangoPay\Pagination;
8 use MangoPay\Sorting;
9 use MangoPay\SortDirection;
10
11 $api = new MangoPayApi();
12
13 $api->Config->ClientId = 'your-client-id';
14 $api->Config->ClientPassword = 'your-api-key;
15 $api->Config->TemporaryFolder = 'your-temporary-folder-path';
16 $api->Config->DebugMode = false;
17
18 try {
19 $pagination = new Pagination(1, 100);
20 $sorting = new Sorting();
21 $sorting->AddField("CreationDate", SortDirection::DESC);
22
23 $list = $api->Users->GetAll($pagination);
24
25 print_r($list);
26 } catch(MGPResponseException $e) {
27 print_r($e);
28 } catch(MGPException $e) {
29 print_r($e);
30 }

Temporary folder

To ensure smooth authentication processes, it’s important to manage the temporary token file effectively.  The temporary file, typically named MangoPaySdkStorage.tmp.php, stores authentication tokens and related temporary data during system operations. 

We recommend creating a dedicated folder to store the generated temporary file within the root directory of your application. When initializing your SDK, include your temporary folder path in the configuration:

1$api->Config->TemporaryFolder = 'your-temporary-folder-path';

If you experience problems with the authentication or the temporary token file, you may need to delete your temporary file that is located in the folder path that you specify with. This allows it to be regenerated correctly the next time it’s needed.

Logging

The Mangopay SDK can integrate the Symfony Logger component. To use this feature, you need to enable debug mode:

1use Symfony\Component\Console\Logger\ConsoleLogger;
2use Symfony\Component\Console\Output\ConsoleOutput;
3
4$api = new MangoPayApi();
5
6$api->Config->ClientId = 'your-client-id';
7$api->Config->ClientPassword = 'your-api-key';
8$api->Config->TemporaryFolder = 'your-temporary-folder-path';
9$api->Config->DebugMode = true;
10
11...

In debug mode, you will be able to see the logging response:

Output - View a user
1<pre>++++++++++++++++++++++ New request ++++++++++++++++++++++: <br />-------------------------------</pre><pre>FullUrl: https://api.sandbox.mangopay.com/v2.01/your-client-id/users/210513027<br />-------------------------------</pre><pre>RequestType: GET<br />-------------------------------</pre><pre>HTTP Headers: Array
2(
3 [0] => Content-Type: application/json
4 [1] => User-Agent: MangoPay V2 SDK PHP 3.27.0
5 [2] => Authorization: bearer 6c2c0d1ee7d348afa1a7e69f648e739f
6)
7<br />-------------------------------</pre><pre>Response JSON: {"Address":{"AddressLine1":"AddressLine1","AddressLine2":"AddressLine2","City":"City","Region":"Region","PostalCode":"11222","Country":"FR"},"FirstName":"Victor","LastName":"Hugo","Birthday":null,"Nationality":null,"CountryOfResidence":null,"Occupation":null,"IncomeRange":null,"ProofOfIdentity":"213918409","ProofOfAddress":null,"Capacity":"NORMAL","PhoneNumber":null,"PhoneNumberCountry":null,"OTPCodeSent":false,"Id":"210513027","Tag":"custom tag","CreationDate":1701775105,"PersonType":"NATURAL","Email":"victor@hugo.com","KYCLevel":"REGULAR","TermsAndConditionsAccepted":false,"TermsAndConditionsAcceptedDate":null,"UserCategory":"PAYER","UserStatus":"ACTIVE"}<br />-------------------------------</pre><pre>Response object: stdClass Object
8(
9 [Address] => stdClass Object
10 (
11 [AddressLine1] => AddressLine1
12 [AddressLine2] => AddressLine2
13 [City] => City
14 [Region] => Region
15 [PostalCode] => 11222
16 [Country] => FR
17 )
18
19 [FirstName] => Victor
20 [LastName] => Hugo
21 [Birthday] =>
22 [Nationality] =>
23 [CountryOfResidence] =>
24 [Occupation] =>
25 [IncomeRange] =>
26 [ProofOfIdentity] => 213918409
27 [ProofOfAddress] =>
28 [Capacity] => NORMAL
29 [PhoneNumber] =>
30 [PhoneNumberCountry] =>
31 [OTPCodeSent] =>
32 [Id] => 210513027
33 [Tag] => custom tag
34 [CreationDate] => 1701775105
35 [PersonType] => NATURAL
36 [Email] => victor@hugo.com
37 [KYCLevel] => REGULAR
38 [TermsAndConditionsAccepted] =>
39 [TermsAndConditionsAcceptedDate] =>
40 [UserCategory] => PAYER
41 [UserStatus] => ACTIVE
42)
43<br />-------------------------------</pre><pre>Response headers: Array
44(
45 [0] => HTTP/2 200 -
46 [1] => date: Tue, 26 Mar 2024 12:34:59 GMT
47 [2] => content-type: application/json; charset=utf-8
48 [3] => content-length: 665
49 [4] => cache-control: no-cache
50 [5] => pragma: no-cache
51 [6] => expires: -1
52 [7] => x-ratelimit: 6
53 [8] => x-ratelimit-remaining: 2294
54 [9] => x-ratelimit-reset: 1711457340
55 [10] => x-ratelimit: 13
56 [11] => x-ratelimit-remaining: 4487
57 [12] => x-ratelimit-reset: 1711458240
58 [13] => x-ratelimit: 13
59 [14] => x-ratelimit-remaining: 8787
60 [15] => x-ratelimit-reset: 1711460040
61 [16] => x-ratelimit: 101
62 [17] => x-ratelimit-remaining: 105499
63 [18] => x-ratelimit-reset: 1711542780
64 [19] => server: APISIX{"Address":{"AddressLine1":"AddressLine1","AddressLine2":"AddressLine2","City":"City","Region":"Region","PostalCode":"11222","Country":"FR"},"FirstName":"Victor","LastName":"Hugo","Birthday":null,"Nationality":null,"CountryOfResidence":null,"Occupation":null,"IncomeRange":null,"ProofOfIdentity":"213918409","ProofOfAddress":null,"Capacity":"NORMAL","PhoneNumber":null,"PhoneNumberCountry":null,"OTPCodeSent":false,"Id":"210513027","Tag":"custom tag","CreationDate":1701775105,"PersonType":"NATURAL","Email":"victor@hugo.com","KYCLevel":"REGULAR","TermsAndConditionsAccepted":false,"TermsAndConditionsAcceptedDate":null,"UserCategory":"PAYER","UserStatus":"ACTIVE"}
65)
66<br />-------------------------------</pre>MangoPay\UserNatural Object
67(
68 [Id] => 210513027
69 [Tag] => custom tag
70 [CreationDate] => 1701775105
71 [PersonType] => NATURAL
72 [Email] => victor@hugo.com
73 [KYCLevel] => REGULAR
74 [TermsAndConditionsAccepted] =>
75 [TermsAndConditionsAcceptedDate] =>
76 [UserCategory] => PAYER
77 [FirstName] => Victor
78 [LastName] => Hugo
79 [Address] => MangoPay\Address Object
80 (
81 [AddressLine1] => AddressLine1
82 [AddressLine2] => AddressLine2
83 [City] => City
84 [Region] => Region
85 [PostalCode] => 11222
86 [Country] => FR
87 )
88
89 [Birthday] =>
90 [Nationality] =>
91 [CountryOfResidence] =>
92 [Occupation] =>
93 [IncomeRange] =>
94 [ProofOfIdentity] => 213918409
95 [ProofOfAddress] =>
96 [Capacity] => NORMAL
97)

You can also provide your own logger:

Call - View a user
1<?php
2
3require_once 'vendor/autoload.php';
4
5use MangoPay\MangoPayApi;
6use MangoPay\Libraries\ResponseException as MGPResponseException;
7use MangoPay\Libraries\Exception as MGPException;
8use Symfony\Component\Console\Logger\ConsoleLogger;
9use Symfony\Component\Console\Output\ConsoleOutput;
10
11try {
12 $api = new MangoPayApi();
13
14 $api->Config->ClientId = 'your-api-key';
15 $api->Config->ClientPassword = 'your-api-key';
16 $api->Config->TemporaryFolder = 'your-temporary-folder-path';
17 $api->Config->DebugMode = true;
18
19 $logger = new ConsoleLogger(new ConsoleOutput());
20 $api->setLogger($logger);
21
22 $userId = '210513027';
23 $user = $api->Users->Get($userId);
24
25 MangoPay\Libraries\Logs::Debug('USER DETAILS', $user);
26
27 print_r($user);
28} catch(MGPResponseException $e) {
29 // Log response exception
30 MangoPay\Libraries\Logs::Debug('MangoPay\ResponseException Code', $e->GetCode());
31 MangoPay\Libraries\Logs::Debug('Message', $e->GetMessage());
32 MangoPay\Libraries\Logs::Debug('Details', $e->GetErrorDetails());
33 // Output response exception
34 print_r($e);
35} catch(MGPException $e) {
36 // Log general exception
37 MangoPay\Libraries\Logs::Debug('MangoPay\Exception Message', $e->GetMessage());
38 // Output general exception
39 print_r($e);
40}
Output
1<pre>++++++++++++++++++++++ New request ++++++++++++++++++++++: <br />-------------------------------</pre><pre>FullUrl: https://api.sandbox.mangopay.com/v2.01/your-client-id/users/210513028<br />-------------------------------</pre><pre>RequestType: GET<br />-------------------------------</pre><pre>HTTP Headers: Array
2(
3 [0] => Content-Type: application/json
4 [1] => User-Agent: MangoPay V2 SDK PHP 3.27.0
5 [2] => Authorization: bearer 6c2c0d1ee7d348afa1a7e69f648e739f
6)
7<br />-------------------------------</pre><pre>Response JSON: {"Message":"The ressource does not exist","Type":"ressource_not_found","Id":"4ebf333e-fcf7-4261-b301-4a7e2c452014","Date":1711456685.0,"errors":{"RessourceNotFound":"Cannot found the ressource User with the id=210513028 "}}<br />-------------------------------</pre><pre>Response object: stdClass Object
8(
9 [Message] => The ressource does not exist
10 [Type] => ressource_not_found
11 [Id] => 4ebf333e-fcf7-4261-b301-4a7e2c452014
12 [Date] => 1711456685
13 [errors] => stdClass Object
14 (
15 [RessourceNotFound] => Cannot found the ressource User with the id=210513028
16 )
17
18)
19<br />-------------------------------</pre><pre>MangoPay\ResponseException Code: 404<br />-------------------------------</pre><pre>Message: Not found. The ressource does not exist<br />-------------------------------</pre><pre>Details: MangoPay\Libraries\Error Object
20(
21 [Message] => The ressource does not exist
22 [Errors] => stdClass Object
23 (
24 [RessourceNotFound] => Cannot found the ressource User with the id=210513028
25 )
26
27 [Id] => 4ebf333e-fcf7-4261-b301-4a7e2c452014
28 [Date] => 1711456685
29 [Type] => ressource_not_found
30)
31<br />-------------------------------</pre>MangoPay\Libraries\ResponseException Object
32(
33 [message:protected] => Not found. The ressource does not exist
34 [string:Exception:private] =>
35 [code:protected] => 404
36 [file:protected] => RestTool.php file path
37 [line:protected] => 393
38 [trace:Exception:private] => Array
39 (
40 [0] => Array
41 (
42 [file] => RestTool.php file path
43 [line] => 161
44 [function] => CheckResponseCode
45 [class] => MangoPay\Libraries\RestTool
46 [type] => ->
47 [args] => Array
48 (
49 [0] => 404
50 [1] => stdClass Object
51 (
52 [Message] => The ressource does not exist
53 [Type] => ressource_not_found
54 [Id] => 4ebf333e-fcf7-4261-b301-4a7e2c452014
55 [Date] => 1711456685
56 [errors] => stdClass Object
57 (
58 [RessourceNotFound] => Cannot found the ressource User with the id=210513028
59 )
60
61 )
62
63 )
64
65 )
66
67 [1] => Array
68 (
69 [file] => ApiBase.php file path
70 [line] => 318
71 [function] => Request
72 [class] => MangoPay\Libraries\RestTool
73 [type] => ->
74 [args] => Array
75 (
76 [0] => /users/210513028
77 [1] => GET
78 )
79
80 )
81
82 [2] => Array
83 (
84 [file] => ApiUsers.php file path
85 [line] => 57
86 [function] => GetObject
87 [class] => MangoPay\Libraries\ApiBase
88 [type] => ->
89 [args] => Array
90 (
91 [0] => users_get
92 [1] =>
93 [2] => 210513028
94 )
95
96 )
97
98 [3] => Array
99 (
100 [file] => current file path
101 [line] => 23
102 [function] => Get
103 [class] => MangoPay\ApiUsers
104 [type] => ->
105 [args] => Array
106 (
107 [0] => 210513028
108 )
109
110 )
111
112 )
113
114 [previous:Exception:private] =>
115 [_responseCodes:MangoPay\Libraries\ResponseException:private] => Array
116 (
117 [200] => OK
118 [204] => No Content
119 [206] => PartialContent
120 [400] => Bad request
121 [401] => Unauthorized
122 [403] => Prohibition to use the method
123 [404] => Not found
124 [405] => Method not allowed
125 [413] => Request entity too large
126 [422] => Unprocessable entity
127 [500] => Internal server error
128 [501] => Not implemented
129 )
130
131 [_errorInfo:MangoPay\Libraries\ResponseException:private] => MangoPay\Libraries\Error Object
132 (
133 [Message] => The ressource does not exist
134 [Errors] => stdClass Object
135 (
136 [RessourceNotFound] => Cannot found the ressource User with the id=210513028
137 )
138
139 [Id] => 4ebf333e-fcf7-4261-b301-4a7e2c452014
140 [Date] => 1711456685
141 [Type] => ressource_not_found
142 )
143
144 [_code:MangoPay\Libraries\ResponseException:private] => 404
145 [RequestUrl] => https://api.sandbox.mangopay.com/v2.01/your-client-id/users/210513028
146)

Rate limits status

The Mangopay PHP SDK provides a way of verifying how many API calls were made, how many are left and when the counter will be reset. 

There are 4 groups of rate limits available:

  • Last 15 minutes
  • Last 30 minutes
  • Last 60 minutes
  • Last 24 hours

This rate limits status information is available from the MangoPayApi instance.

For more information, see the rate limiting article.

1<?php
2
3require_once 'vendor/autoload.php';
4
5use MangoPay\MangoPayApi;
6
7class MangoPayService
8{
9
10 /**
11 * @var MangoPay\MangoPayApi
12 */
13 private $mangoPayApi;
14
15 public function __construct()
16 {
17 $this->mangoPayApi = new MangoPay\MangoPayApi();
18 $this->mangoPayApi->Config->ClientId = 'your-client-id';
19 $this->mangoPayApi->Config->ClientPassword = 'your-api-key';
20 $this->mangoPayApi->Config->TemporaryFolder = 'your-temporary-folder-path';
21 }
22
23 public function verifyRateLimits()
24 {
25 // This is an array of 4 RateLimit objects.
26 $rateLimits = $this->mangoPayApi->RateLimits;
27 print "\nThere were " . $rateLimits[0]->CallsMade . " calls made in the last 15 minutes";
28 print "\nYou can do " . $rateLimits[0]->CallsRemaining . " more calls in the next 15 minutes";
29 print "\nThe 60 minutes counter will reset at " . date("Y-m-d\TH:i:s\Z", $rateLimits[0]->ResetTimeTimestamp);
30 print "\nThere were " . $rateLimits[2]->CallsMade . " calls made in the last 60 minutes";
31 print "\nYou can do " . $rateLimits[2]->CallsRemaining . " more calls in the next 60 minutes";
32 print "\nThe 60 minutes counter will reset at " . date("Y-m-d\TH:i:s\Z", $rateLimits[2]->ResetTimeTimestamp);
33 }
34}

In debug mode, you can also see the response header in your output:

1...
2<br />-------------------------------</pre><pre>Response headers: Array
3(
4 [0] => HTTP/2 200 -
5 [1] => date: Tue, 26 Mar 2024 12:34:59 GMT
6 [2] => content-type: application/json; charset=utf-8
7 [3] => content-length: 665
8 [4] => cache-control: no-cache
9 [5] => pragma: no-cache
10 [6] => expires: -1
11 [7] => x-ratelimit: 6
12 [8] => x-ratelimit-remaining: 2294
13 [9] => x-ratelimit-reset: 1711457340
14 [10] => x-ratelimit: 13
15 [11] => x-ratelimit-remaining: 4487
16 [12] => x-ratelimit-reset: 1711458240
17 [13] => x-ratelimit: 13
18 [14] => x-ratelimit-remaining: 8787
19 [15] => x-ratelimit-reset: 1711460040
20 [16] => x-ratelimit: 101
21 [17] => x-ratelimit-remaining: 105499
22 [18] => x-ratelimit-reset: 1711542780
23 [19] => server: APISIX{"Address":{"AddressLine1":"AddressLine1","AddressLine2":"AddressLine2","City":"City","Region":"Region","PostalCode":"11222","Country":"FR"},"FirstName":"Victor","LastName":"Hugo","Birthday":null,"Nationality":null,"CountryOfResidence":null,"Occupation":null,"IncomeRange":null,"ProofOfIdentity":"213918409","ProofOfAddress":null,"Capacity":"NORMAL","PhoneNumber":null,"PhoneNumberCountry":null,"OTPCodeSent":false,"Id":"210513027","Tag":"custom tag","CreationDate":1701775105,"PersonType":"NATURAL","Email":"victor@hugo.com","KYCLevel":"REGULAR","TermsAndConditionsAccepted":false,"TermsAndConditionsAcceptedDate":null,"UserCategory":"PAYER","UserStatus":"ACTIVE"}
24)
25...

Unit tests

All tests are placed under /your-project-path/tests/. 

You can also use any of the files in /tests/Cases folder to run a single test case.

Error handling

The SDK provides the ResponseException class to wrap HTTP errors from the API, which extends PHP’s native \Exception class.

You can use a standard PHP try…catch block to handle API errors, for example:

1try {
2 $walletId = 'wlt_m_01K3K8QFMNRKSNED3S3EN8EF2X';
3 $response = $api->Wallets->Get($walletId, $scaContext = 'USER_PRESENT');
4 print_r($response);
5} catch (\MangoPay\Libraries\ResponseException $exception) {
6
7 print_r($exception->GetErrorDetails()->Data['RedirectUrl']);
8}