A Laravel package to send SMS via Beem Africa using Laravel Notifications.
# Laravel Beem Africa
A comprehensive Laravel package for integrating with Beem Africa's 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
- **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
```bash
composer require mg-techlegend/laravel-beem-africa
```
Publish the configuration file:
```bash
php artisan vendor:publish --tag="laravel-beem-africa-config"
```
## Configuration
Add these to your `.env` file:
```env
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
### Quick SMS
```php
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
```php
use TechLegend\LaravelBeemAfrica\BeemAfrica …