PHPackages                             beem/laravel-beem - 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. [Framework](/categories/framework)
4. /
5. beem/laravel-beem

ActiveLibrary[Framework](/categories/framework)

beem/laravel-beem
=================

Beem for Laravel

v1.0.0(4y ago)04[2 PRs](https://github.com/beem-dev/laravel-beem/pulls)MITPHPPHP ^7.3|^8.0

Since Apr 25Pushed 2y agoCompare

[ Source](https://github.com/beem-dev/laravel-beem)[ Packagist](https://packagist.org/packages/beem/laravel-beem)[ Docs](https://github.com/beem-dev/laravel-beem)[ Patreon](https://www.patreon.com/alphaolomi)[ RSS](/packages/beem-laravel-beem/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (12)Versions (5)Used By (0)

Laravel Beem
============

[](#laravel-beem)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fd5bf06ea1aa3f7784ae59677c5087b0ac80b043d598da14933dd7766f3a55fd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6265656d2f6c61726176656c2d6265656d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beem/laravel-beem)[![GitHub Tests Action Status](https://camo.githubusercontent.com/f2758df725482f3adf19c5fb49671f2cb9c3b5778bde18bafdfbd93e8f4f0417/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6265656d2d6465762f6c61726176656c2d6265656d2f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/beem-dev/laravel-beem/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/4f9db9b59d8c862a0da55852a90dd5f632a0c6a61534171b2172e68d211ef38b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6265656d2d6465762f6c61726176656c2d6265656d2f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/beem-dev/laravel-beem/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/795fc31a85b5a726e585412c411cd89707b0c11ba7a2accb6739a25035ee600f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6265656d2f6c61726176656c2d6265656d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beem/laravel-beem)

This package enables Laravel developers to integrate their websites/APIs with all Beem API services

**Table of Contents**

- [Laravel Beem](#laravel-beem)
    - [Installation](#installation)
    - [Configuration](#configuration)
    - [Usage](#usage)
        - [1. SMS](#1-sms)
            - [SMS Delivery Reports](#sms-delivery-reports)
                - [Collecting the delivery data](#collecting-the-delivery-data)
            - [SMS templates](#sms-templates)
            - [Two-Way SMS](#two-way-sms)
                - [Collecting the outbound sms data](#collecting-the-outbound-sms-data)
        - [2. Contacts](#2-contacts)
        - [3. USSD](#3-ussd)
            - [Collecting USSD callback data](#collecting-ussd-callback-data)
            - [Checking the USSD balance](#checking-the-ussd-balance)
        - [4. Airtime](#4-airtime)
            - [Airtime callback success](#airtime-callback-success)
                - [Collecting airtime callback data](#collecting-airtime-callback-data)
            - [Querying airtime transaction status](#querying-airtime-transaction-status)
            - [Checking the airtime balance](#checking-the-airtime-balance)
        - [5. Payment Collection](#5-payment-collection)
            - [Collecting payment collection callback data](#collecting-payment-collection-callback-data)
            - [Checking the payment collection balance](#checking-the-payment-collection-balance)
        - [6. Payment Checkout](#6-payment-checkout)
            - [Payment checkout callback](#payment-checkout-callback)
            - [Collecting payment checkout callback data](#collecting-payment-checkout-callback-data)
        - [7. Disbursements](#7-disbursements)
        - [8. OTP](#8-otp)
    - [Debugging Tips](#debugging-tips)
    - [Testing](#testing)
    - [Changelog](#changelog)
    - [Contributing](#contributing)
    - [Security Vulnerabilities](#security-vulnerabilities)
    - [Credits](#credits)
    - [License](#license)

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

[](#installation)

Pre-installation requirements

- Supports Laravel projects starting version 8.\*
- Minimum PHP version is 7.4
- Your server must have the cURL PHP extension (ext-curl) installed

Then proceed to install

```
composer require beem/laravel-beem
```

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

[](#configuration)

To access Beem's APIs, you will need to provide the package with access to your Beem API Key and Secret Key.

For this we need to publish the package's configuration file using:

```
php artisan vendor:publish --tag=beem-config
```

After you have created a Beem vendor account and obtained the keys on the dashboard, add their values in the `.env` variables

```
BEEM_KEY=yourApiKey
BEEM_SECRET=yourSecretKey
```

Usage
-----

[](#usage)

### 1. SMS

[](#1-sms)

To send an SMS message, use the Beem facade and pass the message and recipients as arguments

```
use Beem\Laravel\Facades\Beem;

$recipients = [
    [
        'recipient_id' => (string) 1,
        'dest_addr' => (string) 255784000000,
    ],
    [
        'recipient_id' => (string) 2,
        'dest_addr' => (string) 255754000000,
    ],
];

Beem::sms('This is the message', $recipients);
```

Optionally, you can include your custom sender name only if the request has been accepted on your vendor dashboard.

The default sender name is 'INFO'. You can change it by passing the `sender_name` argument. While using the default sender name, Beem can use another sender while sending the message example `'ONSMS'`.

```
Beem::sms('Another message', $recipients, 'SENDER-NAME');
```

For scheduled SMS, you can use a datetime value or `Carbon\Carbon` instance, but make sure the timezone is GMT+0

```
$time = now()->addHours(10);

Beem::smsWithSchedule('Reminder message', $recipients, $time, 'SENDER-NAME');
```

You can also check the remaining SMS balance using

```
Beem::smsBalance()->json();
```

#### SMS Delivery Reports

[](#sms-delivery-reports)

If you have specified a callback URL in the account profile, you can use that route in any way.

Optionally, this package comes with:

- A customizable callback route `/beem/sms-delivery-report`. The prefix can be changed using a `.env` value for `BEEM_PATH`. Once it is changed, the route becomes `/{env-value}/sms-delivery-report` (remember to update this callback on the vendor dashboard).
- An event `Beem\Laravel\Events\SmsDeliveryReportReceived` to collect Beem's data once they are sent to the callback.

##### Collecting the delivery data

[](#collecting-the-delivery-data)

To use the event above, assign a listener in the `App\Providers\EventServiceProvider`

```
class EventServiceProvider extends ServiceProvider
{
    protected $listen = [
        \Beem\Laravel\Events\SmsDeliveryReportReceived::class => [
            \App\Listeners\ProcessDeliveryReport::class,
        ],
    ];
}
```

After you create the listener class, you can use Beem's delivery report

```
