Roamtech Gateway API implementation

v0.1.3 2020-08-05 07:17 UTC

This package is auto-updated.

Last update: 2022-12-05 12:39:37 UTC



Pull in the package through Composer to get the latest stable version.

$ composer require roamtech/gateway-api

Native Addon

When using vanilla PHP, modify your composer.json file to include:

  "scripts": {
    "post-update-cmd": [

This script will copy the default configuration file to a config folder in the root directory of your project. Now proceed to require the package.


When using Laravel 5.5+, the package will automatically register. For laravel 5.4 and below, include the service provider and its alias within your config/app.php.

'providers' => [

Publish the package specific config using:

php artisan vendor:publish --provider 'Roamtech\Gateay\Laravel\ServiceProvider'


Vanilla PHP

For Vanilla PHP you will need to initialize the sdk bootstrapper to get started.

use GuzzleHttp\Client;
use Roamtech\Gateway\Engine\Core;
use Roamtech\Gateway\Native\NativeCache;
use Roamtech\Gateway\Native\NativeConfig;
use Roamtech\Gateway\Client as GatewayClient;

require "vendor/autoload.php";

$config = new NativeConfig(__DIR__.'/config/roamtechapi.php');
// Configure the HTTP client
$client = new Client(['base_uri' => $config->get('roamtechapi.api_endpoint')]);
$core = new Core($client, $config, new NativeCache($config));
$gateway = new GatewayClient($core);


Laravel configuration is straight forward. After installation the API client is registered in the service container as:

$gateway = resolve('roamtech.client');
// Or Type hint it in method definitions
use Roamtech\Gateway\Client as GatewayClient;

class Mycontroller extends Controller {
     * @var GatewayClient 
    private $apiClient;
     * Inject client in constructor
     * @param GatewayClient $apiClient
    public function __construct(GatewayClient $apiClient)
        $this->apiClient = $apiClient;


Send Bulk SMS

Send SMS in bulk mode, this endpoints allows you to send multiple messages in a single API call.

$messages = [
    ['recipient' => '25472xxxxxxx', 'message' => 'This is a test message'],
    ['recipient' => '25471xxxxxxx', 'message' => 'This is a a custom message']
// Using the gateway instance we can now invoke the API with our payload

$response = $gateway->sms()->sendBulkMessages($messages, ['from' => 'YourSenderId']);

Send single SMS

This API allows you to send a single message to one or multiple recipients.

$recipients = ['25472xxxxxxx', '25471xxxxxxx'];
$message = 'A test message to say hello';
$options = [
    'from' => 'YourSenderId'
    'messageId' => '345623', 
    'callback' => '',

// Let us send our message 
$response = $gateway->sms()->sendMessage($message, $recipients, $options);

Get Delivery reports

To get delivery reports for messages use this snipet

$messageId = '448768fjkhgcs4cykxuy8747r9c489';
$response = $gateway->sms()->getDeliveryReport($messageId);


You can also credit airtime to your customers instantly. This Api is asynchronous when you initiate a request our API will respond back to you with the transaction and a pending status. We will then send a callback to your application with the final status.

$recipients = [
        'phoneNumber' => '25472xxxxxxx',
        'amount' => 10
        'phoneNumber' => '25471xxxxxxx',
        'amount' => 10
$callback = '';

// initiate the airtime purchase transaction
$response = $gateway->airtime()