PHPackages                             bryceandy/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. [API Development](/categories/api)
4. /
5. bryceandy/laravel-beem

ActiveLibrary[API Development](/categories/api)

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

A package to integrate your Laravel app with Beem API services(SMS, Contacts, USSD, Airtime, Payment Collections, Payment Checkout, Disbursements and OTP).

v1.0.4(4y ago)103815[1 PRs](https://github.com/bryceandy/laravel-beem/pulls)MITPHPPHP ^7.4|^8.0

Since Jul 16Pushed 4y ago1 watchersCompare

[ Source](https://github.com/bryceandy/laravel-beem)[ Packagist](https://packagist.org/packages/bryceandy/laravel-beem)[ Patreon](https://www.patreon.com/bryceandy)[ RSS](/packages/bryceandy-laravel-beem/feed)WikiDiscussions master Synced 3w ago

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

[![](https://camo.githubusercontent.com/c7ccb9d24317b53598ebe8cf2fd2053ae4bf5115c5f20265ef1a873ec2f4912b/68747470733a2f2f6265656d2e6166726963612f77702d636f6e74656e742f75706c6f6164732f323032302f31322f4265656d2d6d656e752d6c6f676f2d30322e737667)](https://camo.githubusercontent.com/c7ccb9d24317b53598ebe8cf2fd2053ae4bf5115c5f20265ef1a873ec2f4912b/68747470733a2f2f6265656d2e6166726963612f77702d636f6e74656e742f75706c6f6164732f323032302f31322f4265656d2d6d656e752d6c6f676f2d30322e737667)

Beem package for Laravel apps
=============================

[](#beem-package-for-laravel-apps)

[![Actions Status](https://github.com/bryceandy/laravel-beem/workflows/Tests/badge.svg)](https://github.com/bryceandy/laravel-beem/actions)[![Total Downloads](https://camo.githubusercontent.com/caec4d43f9328300592b46f1fc903be6f66429bd2f518ef7a3a30857ef2e46ad/68747470733a2f2f706f7365722e707567782e6f72672f6272796365616e64792f6c61726176656c2d6265656d2f642f746f74616c2e737667)](https://packagist.org/packages/bryceandy/laravel-beem)[![Latest Stable Version](https://camo.githubusercontent.com/e18eb31803799bd1bfd4f0077d17b942faad73c6a77860b15f97e3de56ed7cbb/68747470733a2f2f706f7365722e707567782e6f72672f6272796365616e64792f6c61726176656c2d6265656d2f762f737461626c652e737667)](https://packagist.org/packages/bryceandy/laravel-beem)[![License](https://camo.githubusercontent.com/99d3e58b5a8ce2e2c24adafa84695c6981547b95f406c78480273c2533267ce3/68747470733a2f2f706f7365722e707567782e6f72672f6272796365616e64792f6c61726176656c2d6265656d2f6c6963656e73652e737667)](https://packagist.org/packages/bryceandy/laravel-beem)

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

**Table of Contents**

- [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 callback data](#collecting-ussd-callback-data)
        - [Checking the balance](#checking-the-ussd-balance)
    4. [Airtime](#4-airtime)
        - [Airtime callback success](#airtime-callback-success)
        - [Collecting callback data](#collecting-airtime-callback-data)
        - [Querying airtime transaction status](#querying-airtime-transaction-status)
        - [Checking the balance](#checking-the-airtime-balance)
    5. [Payment Collection](#5-payment-collection)
        - [Collecting callback data](#collecting-payment-collection-callback-data)
        - [Checking the balance](#checking-the-payment-collection-balance)
    6. [Payment Checkout](#6-payment-checkout)
        - [Payment checkout callback](#payment-checkout-callback)
        - [Collecting callback data](#collecting-payment-checkout-callback-data)
    7. [Disbursements](#7-disbursements)
    8. [OTP](#8-otp)
- [Debugging Tips](#debugging-tips)
- [License](#license)
- [Contributing](#contributing)

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 bryceandy/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 Bryceandy\Beem\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'.

```
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 `Bryceandy\Beem\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 = [
        \Bryceandy\Beem\Events\SmsDeliveryReportReceived::class => [
            \App\Listeners\ProcessDeliveryReport::class,
        ],
    ];
}
```

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

```
