Developer - API - Purse balance

function balance($purse = '')

POST Get balance
Parameter Type Value Required Description
$purse string empty, U12345678 No Account purse. If purse is not provided, return balance of all purses

Sometimes it may happen that API may not work due to server or developer fault. To identify the problem, API returns error code with message what has happend wrong.

Error Code Description
-1 API information is not valid
-2 API was disabled
-3 This IP %s has no access
1 Purse does not exist

Code Snippets

<?php
// Include lib
require_once 'path/to/entromoney/api/api.php';

// Api config
$config = array();
$config['api_user']	= 'ACCOUNT_ID';
$config['api_id']	= 'API_ID';
$config['api_pass']	= 'API_PASS';

// Call lib
try {
	$api = new Paygate_Api($config);
}
catch (Paygate_Exception $e) {
	exit($e->getMessage());
}

// Get balance of all purses
$res = $api->balance();
print_r($res);

// Get balance of purse
$res = $api->balance('U12345678');
print_r($res);
?>

Response

// $res = $api->balance();
stdClass Object
(
    [status] => 1
    [result] => stdClass Object
        (
            [U12345678] => 123.45
            [E87654321] => 987.65
        )
)

// $res = $api->balance('U12345678');
stdClass Object
(
    [status] => 1
    [result] => 123.45
)