PHPackages                             mg-techlegend/laravel-beem-africa - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. mg-techlegend/laravel-beem-africa

ActiveLibrary[API Development](/categories/api)

mg-techlegend/laravel-beem-africa
=================================

A comprehensive Laravel package for integrating with Beem Africa's API services including SMS, OTP, Airtime, USSD, Voice, and Insights. Provides a clean, expressive interface with Laravel Notifications support, typed responses, and robust error handling.

v3.0.0(3mo ago)154[4 PRs](https://github.com/mg-techlegend/laravel-beem-africa/pulls)MITPHPPHP ^8.4CI passing

Since May 21Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/mg-techlegend/laravel-beem-africa)[ Packagist](https://packagist.org/packages/mg-techlegend/laravel-beem-africa)[ Docs](https://github.com/mg-techlegend/laravel-beem-africa)[ GitHub Sponsors](https://github.com/TechLegend)[ RSS](/packages/mg-techlegend-laravel-beem-africa/feed)WikiDiscussions main Synced today

READMEChangelog (9)Dependencies (22)Versions (17)Used By (0)

Laravel Beem Africa
===================

[](#laravel-beem-africa)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a2974ac07dd27cb37443d718f7512578748fff6f4afe74caa5adf28f46b50eae/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d672d746563686c6567656e642f6c61726176656c2d6265656d2d6166726963612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mg-techlegend/laravel-beem-africa)[![GitHub Tests Action Status](https://camo.githubusercontent.com/3b6e91bb12384f8972bd05e4fcb8ad3ef48afb03c091457ac271a25b4310e46c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d672d746563686c6567656e642f6c61726176656c2d6265656d2d6166726963612f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/mg-techlegend/laravel-beem-africa/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/7f510627f23e9baeca806175e4ec22a5f237f9e64a418ed7e00afec461ca6e90/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d672d746563686c6567656e642f6c61726176656c2d6265656d2d6166726963612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mg-techlegend/laravel-beem-africa)

A comprehensive Laravel package for integrating with [Beem Africa's](https://beem.africa) API services. Provides a clean, expressive interface for SMS, OTP, Airtime, USSD, Voice, and Insights with Laravel Notifications support, typed responses, and robust error handling.

Features
--------

[](#features)

- **SMS** - Single and bulk messaging with fluent message builder
- **OTP** - Generate, verify, and resend one-time passwords
- **Airtime** - Send airtime, check balance, transaction history
- **USSD** - Create, update, list, and delete USSD menus
- **Voice** - Make calls, check status, list available voices
- **Insights** - Delivery reports, message statistics, account balance
- **Webhooks** - Handle delivery reports with HMAC signature verification
- **Laravel Notifications** - Native notification channel integration
- **Typed Responses** - Readonly DTOs for all API responses
- **Error Handling** - Specific exceptions for auth, validation, and request errors
- **Phone Normalization** - Automatic formatting with optional country code prefixing
- **HTTP Retries** - Configurable retry logic for resilient requests

Installation
------------

[](#installation)

```
composer require mg-techlegend/laravel-beem-africa
```

Publish the configuration file:

```
php artisan vendor:publish --tag="laravel-beem-africa-config"
```

Configuration
-------------

[](#configuration)

Add these to your `.env` file:

```
BEEM_API_KEY=your-api-key
BEEM_SECRET_KEY=your-secret-key
BEEM_SENDER_NAME=YourApp

# Optional
BEEM_DEFAULT_COUNTRY_CODE=255
BEEM_TIMEOUT=30
BEEM_HTTP_RETRY_ATTEMPTS=3
```

Usage
-----

[](#usage)

### Quick SMS

[](#quick-sms)

```
use TechLegend\LaravelBeemAfrica\Facades\LaravelBeemAfrica as BeemAfrica;

// Single SMS
$response = BeemAfrica::sendSms('255700000001', 'Hello from Beem!');

// With custom sender
$response = BeemAfrica::sendSms('255700000001', 'Hello!', 'MyApp');

// Bulk SMS
$response = BeemAfrica::sendSmsBulk(
    ['255700000001', '255700000002'],
    'Bulk message'
);
```

### Fluent Message Builder

[](#fluent-message-builder)

```
use TechLegend\LaravelBeemAfrica\BeemAfricaMessage;
use TechLegend\LaravelBeemAfrica\Facades\LaravelBeemAfrica as BeemAfrica;

$message = BeemAfricaMessage::make()
    ->to('255700000001')
    ->content('Hello World')
    ->sender('MyApp')
    ->encoding(1); // UCS2 encoding

$response = BeemAfrica::sendSmsMessage($message);

echo $response->successful;  // true
echo $response->requestId;   // 12345
echo $response->valid;       // 1
```

### OTP Service

[](#otp-service)

```
// Generate OTP
$response = BeemAfrica::generateOtp('255700000001', [
    'length' => 6,
    'expiry' => 300,
    'type' => 'numeric',
    'message' => 'Your code is: {code}',
]);

echo $response->requestId; // 'otp_123456'

// Verify OTP
$response = BeemAfrica::verifyOtp('255700000001', '123456');

echo $response->valid; // true

// Resend OTP (via service accessor)
$response = BeemAfrica::otp()->resend('255700000001', 'otp_123456');
```

### Airtime

[](#airtime)

```
// Send airtime
$response = BeemAfrica::sendAirtime('255700000001', 1000.00, [
    'currency' => 'TZS',
]);

echo $response->transactionId; // 'txn_123'

// Check balance
$balance = BeemAfrica::airtime()->getBalance();
echo $balance->balance;   // 5000.00
echo $balance->currency;  // 'TZS'
```

### Voice

[](#voice)

```
$response = BeemAfrica::makeCall('255700000001', 'Hello, this is a voice message', [
    'language' => 'en',
    'voice_id' => 1,
    'repeat_count' => 2,
]);

echo $response->callId; // 'call_123'
```

### USSD Menus

[](#ussd-menus)

```
$response = BeemAfrica::ussd()->createMenu([
    'menu_name' => 'My Service',
    'menu_items' => [...],
    'welcome_message' => 'Welcome!',
]);

echo $response->menuId; // 'menu_123'
```

### Insights &amp; Reporting

[](#insights--reporting)

```
// Account balance
$balance = BeemAfrica::getBalance();

// Delivery report
$report = BeemAfrica::insights()->getDeliveryReport('request_123');

// Message statistics
$stats = BeemAfrica::insights()->getMessageStatistics([
    'start_date' => '2024-01-01',
    'end_date' => '2024-01-31',
]);
```

### Service Accessors

[](#service-accessors)

Access individual services for advanced use:

```
BeemAfrica::sms();       // BeemSms
BeemAfrica::otp();       // BeemOtp
BeemAfrica::airtime();   // BeemAirtime
BeemAfrica::ussd();      // BeemUssd
BeemAfrica::voice();     // BeemVoice
BeemAfrica::insights();  // BeemInsights
BeemAfrica::webhooks();  // BeemWebhookHandler
```

### Laravel Notifications

[](#laravel-notifications)

```
use Illuminate\Notifications\Notification;
use TechLegend\LaravelBeemAfrica\BeemAfricaMessage;
use TechLegend\LaravelBeemAfrica\Channels\BeemAfricaChannel;

class OrderShipped extends Notification
{
    public function via(object $notifiable): array
    {
        return [BeemAfricaChannel::class];
    }

    public function toBeemAfrica(object $notifiable): BeemAfricaMessage
    {
        return BeemAfricaMessage::make()
            ->content('Your order has been shipped!')
            ->sender('MyShop');
    }
}
```

Add the routing method to your notifiable model:

```
class User extends Authenticatable
{
    use Notifiable;

    public function routeNotificationForBeemAfrica(): string
    {
        return $this->phone_number;
    }
}
```

### Dependency Injection

[](#dependency-injection)

```
use TechLegend\LaravelBeemAfrica\LaravelBeemAfrica;

class SmsController extends Controller
{
    public function __construct(
        private LaravelBeemAfrica $beem,
    ) {}

    public function send()
    {
        $response = $this->beem->sendSms('255700000001', 'Hello!');
    }
}
```

### Webhooks

[](#webhooks)

```
use TechLegend\LaravelBeemAfrica\Facades\LaravelBeemAfrica as BeemAfrica;

Route::post('/webhooks/beem', function (Request $request) {
    $result = BeemAfrica::webhooks()->handle($request);

    if ($result['successful']) {
        // Process the webhook data
        $eventType = $result['event_type'];
        $data = $result['data'];
    }

    return response()->json(['status' => 'ok']);
});
```

### Error Handling

[](#error-handling)

```
use TechLegend\LaravelBeemAfrica\Exceptions\BeemAfricaAuthenticationException;
use TechLegend\LaravelBeemAfrica\Exceptions\BeemAfricaValidationException;
use TechLegend\LaravelBeemAfrica\Exceptions\BeemAfricaRequestException;

try {
    $response = BeemAfrica::sendSms('255700000001', 'Hello!');
} catch (BeemAfricaAuthenticationException $e) {
    // Invalid API credentials (401/403)
    $e->payload; // Original API response
} catch (BeemAfricaValidationException $e) {
    // Invalid request data (400/422)
} catch (BeemAfricaRequestException $e) {
    // Server error or connection issue (5xx)
}
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Thomson Maguru](https://github.com/mg-techlegend)
- [Beem Africa](https://beem.africa)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance84

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 89.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~35 days

Recently: every ~78 days

Total

10

Last Release

91d ago

Major Versions

1.2.1 → 2.0.0-beta2025-08-30

v2.x-dev → v3.0.02026-04-05

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2600024?v=4)[Thomson Maguru](/maintainers/tomsgad)[@tomsgad](https://github.com/tomsgad)

---

Top Contributors

[![tomsgad](https://avatars.githubusercontent.com/u/2600024?v=4)](https://github.com/tomsgad "tomsgad (43 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

beemlaraveltechlegendlaravelotpsmsInsightswebhooksvoiceairtimeussdbeem-africaTechLegendlaravel-beem-africa

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/mg-techlegend-laravel-beem-africa/health.svg)

```
[![Health](https://phpackages.com/badges/mg-techlegend-laravel-beem-africa/health.svg)](https://phpackages.com/packages/mg-techlegend-laravel-beem-africa)
```

###  Alternatives

[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.9k3](/packages/defstudio-telegraph)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M101](/packages/dedoc-scramble)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.0k](/packages/simplestats-io-laravel-client)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M166](/packages/spatie-laravel-health)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
