Skip to main content

Overview

The ApiWallets class provides methods to create, retrieve, update wallets and manage wallet transactions. Wallets are used to store funds for users in your Mangopay platform.

Methods

Create

Create a new wallet.
public function Create($wallet, $idempotencyKey = null)
wallet
Wallet
required
The wallet object to create
idempotencyKey
string
Optional idempotency key to prevent duplicate requests
Returns: Wallet - The created wallet object Example:
$api = new MangoPay\MangoPayApi();
$api->Config->ClientId = 'your-client-id';
$api->Config->ClientPassword = 'your-api-key';

$wallet = new MangoPay\Wallet();
$wallet->Owners = ['user_id_123'];
$wallet->Description = 'Main wallet';
$wallet->Currency = 'EUR';

$createdWallet = $api->Wallets->Create($wallet);
echo $createdWallet->Id;

Get

Retrieve a wallet by its ID.
public function Get($walletId, $scaContext = null)
walletId
string
required
The wallet identifier
scaContext
string
Optional. Strong Customer Authentication context. Possible values:
  • USER_NOT_PRESENT - User is not present during the operation
  • USER_PRESENT - User is present during the operation
When USER_PRESENT is used and SCA is required, an error containing the RedirectUrl will be thrown
Returns: Wallet - The wallet object Example:
$api = new MangoPay\MangoPayApi();
$api->Config->ClientId = 'your-client-id';
$api->Config->ClientPassword = 'your-api-key';

$wallet = $api->Wallets->Get('wallet_id_123');
echo $wallet->Description;
echo $wallet->Balance->Amount;

// With SCA context
try {
    $wallet = $api->Wallets->Get('wallet_id_123', 'USER_PRESENT');
} catch (Exception $e) {
    // Handle SCA redirect if needed
}

Update

Update an existing wallet.
public function Update($wallet)
wallet
Wallet
required
The wallet object to update (must have an Id)
Returns: Wallet - The updated wallet object Example:
$api = new MangoPay\MangoPayApi();
$api->Config->ClientId = 'your-client-id';
$api->Config->ClientPassword = 'your-api-key';

$wallet = $api->Wallets->Get('wallet_id_123');
$wallet->Description = 'Updated wallet description';

$updatedWallet = $api->Wallets->Update($wallet);
echo $updatedWallet->Description;

GetTransactions

Retrieve all transactions for a specific wallet.
public function GetTransactions($walletId, & $pagination = null, $filter = null, $sorting = null)
walletId
string
required
The wallet identifier
pagination
Pagination
Pagination object to control page size and number
filter
FilterTransactions
Filter object to filter transactions by specific criteria
sorting
Sorting
Sorting object to sort the results
Returns: Transaction[] - Array of transaction objects Example:
$api = new MangoPay\MangoPayApi();
$api->Config->ClientId = 'your-client-id';
$api->Config->ClientPassword = 'your-api-key';

$pagination = new MangoPay\Pagination(1, 10);
$transactions = $api->Wallets->GetTransactions('wallet_id_123', $pagination);

foreach ($transactions as $transaction) {
    echo $transaction->Id . ' - ' . $transaction->Status;
}

echo 'Total pages: ' . $pagination->TotalPages;

Wallet Entity

The Wallet class represents a wallet entity with the following properties:

Properties

Id
string
Unique identifier for the wallet (read-only)
Tag
string
Custom data for the wallet
CreationDate
int
Unix timestamp of when the wallet was created (read-only)
Owners
array
Array of user IDs who own this wallet
Description
string
Description of the wallet
Balance
Money
Current balance in the wallet (read-only)Contains:
  • Amount (int): The amount in the wallet’s smallest currency unit (e.g., cents)
  • Currency (string): ISO 4217 currency code (e.g., “EUR”, “USD”)
Currency
string
ISO 4217 currency code for the wallet (e.g., “EUR”, “USD”, “GBP”)

Example Object

$wallet = new MangoPay\Wallet();
$wallet->Owners = ['user_123', 'user_456'];
$wallet->Description = 'Company main wallet';
$wallet->Currency = 'EUR';
$wallet->Tag = 'department:finance';

Read-Only Properties

The following properties are read-only and cannot be modified:
  • Id
  • CreationDate
  • Balance

Build docs developers (and LLMs) love