Wallets are containers that hold funds for users on the Mangopay platform. Each wallet belongs to one or more users and has a specific currency. Wallets are the central hub for all money movements in Mangopay.
use MangoPay\Wallet;// Wallet properties$wallet->Id; // Unique identifier$wallet->Owners; // Array of user IDs who own the wallet$wallet->Description; // Custom description$wallet->Balance; // Current balance (Money object)$wallet->Currency; // Currency code (EUR, USD, GBP, etc.)
Consider creating different wallets for different purposes (e.g., operating funds, reserve funds, commission wallet) to improve accounting and tracking.
Use descriptive wallet names
Set clear, descriptive names in the Description field to help identify wallet purposes.
Store wallet IDs in your database
Always map wallet IDs to your application’s data model for easy retrieval.
Check balance before operations
Always verify sufficient funds before initiating transfers or payouts.
Monitor wallet transactions regularly
Implement logging and monitoring for all wallet transactions to detect issues early.
Handle currency carefully
Remember that wallets are single-currency. Plan your currency strategy before creating wallets.
// Create a wallet for a seller$sellerWallet = new Wallet();$sellerWallet->Owners = [$sellerId];$sellerWallet->Description = "Seller earnings wallet";$sellerWallet->Currency = "EUR";$sellerWallet = $api->Wallets->Create($sellerWallet);// Create a commission wallet for the platform$commissionWallet = new Wallet();$commissionWallet->Owners = [$platformUserId];$commissionWallet->Description = "Platform commission wallet";$commissionWallet->Currency = "EUR";$commissionWallet = $api->Wallets->Create($commissionWallet);
// Create wallets for each currency a user needs$currencies = ['EUR', 'GBP', 'USD'];$wallets = [];foreach ($currencies as $currency) { $wallet = new Wallet(); $wallet->Owners = [$userId]; $wallet->Description = "{$currency} wallet for User {$userId}"; $wallet->Currency = $currency; $wallets[$currency] = $api->Wallets->Create($wallet);}