User

Balance, profile, payments and the webhook URL — $client->user.

balance

Balance in USD.

public function balance(): array

Returns ['balance' => float, 'zbalance' => float, 'income' => float] (income only when the server sends it). balance includes the sum frozen by numbers and unconfirmed rents in progress (zbalance, which may be negative): available = balance − max(zbalance, 0). income is the partner income. The server caches the answer for 60 s.

$b = $client->user->balance();
$available = $b['balance'] - max($b['zbalance'], 0);

Errors: ApiError ERROR_WRONG_KEY, ACCOUNT_BLOCKED, API_ACCESS_DISABLED, API_ACCESS_IP.

profile

The account profile.

public function profile(): array

Profile: ['id', 'name', 'username', 'email', 'locale', 'currency', 'number_country', 'number_reject', 'webhook_url', 'api_access', 'number', 'country', …] — number is ?int, country ?string.

$profile = $client->user->profile();
echo $profile['email'] ?? '', ' ', $profile['webhook_url'] ?? 'no webhook';

paymentHistory

Top-up orders (paginated, newest first) and the available payment methods.

public function paymentHistory(int $page = 1): array

PaymentHistory: ['orders' => Paginator<PaymentOrder>, 'paylist', 'domains'?, 'forms'?, 'currency'?, 'buttons'?]. PaymentOrder['sum'] stays a decimal string ("89.00"); currency and form_text may be null. paylist maps a group id to its payment methods, or is a list when the ids are 0, 1, 2… (the server sends a JSON array then).

$orders = $client->user->paymentHistory()['orders'];
echo "{$orders['total']} orders, page {$orders['current_page']}/{$orders['last_page']}\n";

setWebhookUrl

Set the URL that receives SMS webhooks (see Webhooks). Returns true.

public function setWebhookUrl(string $url): bool
$client->user->setWebhookUrl('https://example.com/onlinesim-hook');

Errors: ApiError VALIDATION_ERROR for an invalid URL; the message holds the server's field messages.

clearWebhookUrl

Remove the webhook URL, also from operations in progress. Returns true.

public function clearWebhookUrl(): bool
$client->user->clearWebhookUrl();

webhookLogs

Webhook delivery log, newest first, 10 per page.

public function webhookLogs(int $page = 1): array

Returns a paginator (current_page, data, last_page, total, …) of WebhookLog: ['id', 'user_id', 'webhook_url', 'type', 'params', 'status', 'error', 'created_at', 'updated_at'] — type is receiving_sms or rent_sms, status is success, fail or pending, params the payload that was sent.

foreach ($client->user->webhookLogs()['data'] as $log) {
    echo $log['created_at'], ' ', $log['status'], ' ', $log['error'] ?? '', "\n";
}