1. Go to this page and download the library: Download statum/statum-php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
statum / statum-php-sdk example snippets
use Statum\Sdk\StatumClient;
$client = StatumClient::create(
consumerKey: 'your_consumer_key',
consumerSecret: 'your_consumer_secret'
);
use Statum\Sdk\Config\StatumConfig;
use Statum\Sdk\StatumClient;
$config = new StatumConfig(
consumerKey: 'your_key',
consumerSecret: 'your_secret',
baseUrl: 'https://api.statum.co.ke/api/v2', // Optional
timeout: 30.0 // Optional, in seconds
);
$client = new StatumClient($config);
$response = $client->account()->getAccountDetails();
echo "Status Code: " . $response->statusCode;
echo "Organization: " . $response->organization->name;
echo "Available Balance: KES " . $response->organization->details->availableBalance;
echo "Website: " . $response->organization->details->website;
echo "M-Pesa Top Up Code: " . $response->organization->details->mpesaAccountTopUpCode;
// List service accounts
foreach ($response->organization->accounts as $account) {
echo $account->account . " (" . $account->serviceName . ")";
}
use Statum\Sdk\Exceptions\AuthenticationException;
use Statum\Sdk\Exceptions\ValidationException;
use Statum\Sdk\Exceptions\NetworkException;
use Statum\Sdk\Exceptions\ApiException;
try {
$client->airtime()->sendAirtime('254712345678', '100');
} catch (AuthenticationException $e) {
// Invalid credentials (401)
} catch (ValidationException $e) {
// Validation errors from API (422)
echo "Request ID: " . $e->getRequestId();
foreach ($e->getValidationErrors() as $field => $errors) {
echo "$field: " . implode(', ', $errors);
}
} catch (NetworkException $e) {
// Connection/timeout issues
} catch (ApiException $e) {
// General API errors
echo "HTTP Status: " . $e->getCode();
echo "Body: " . $e->getResponseBody();
}
public function register()
{
$this->app->singleton(StatumClient::class, function ($app) {
return StatumClient::create(
config('services.statum.key'),
config('services.statum.secret')
);
});
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.