PHPackages                             bascil/ussd-mobile-money-php - 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. bascil/ussd-mobile-money-php

ActiveLibrary

bascil/ussd-mobile-money-php
============================

This is a PHP package for a mobile money solution on USSD

4721PHP

Since Aug 11Pushed 4y ago2 watchersCompare

[ Source](https://github.com/Bascil/ussd-mobile-money-php)[ Packagist](https://packagist.org/packages/bascil/ussd-mobile-money-php)[ RSS](/packages/bascil-ussd-mobile-money-php/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

PHP package for a mobile money solution on USSD
===============================================

[](#php-package-for-a-mobile-money-solution-on-ussd)

This is a PHP package for a mobile money solution on USSD based on the `Africa's Talking` API. This application has been developed on sandbox (testing) mode. To go live contact `Africa's Talking Ltd` on .

Prerequisites
-------------

[](#prerequisites)

For testing download `Africa's Talking` android app from Google Playstore or use the web interface at

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

[](#installation)

This project supports both composer dependency management tool and can also be used without composer

- Run the following command to clone this repository

```
git clone https://github.com/Bascil/ussd-mobile-money-php.git

```

OR

- Download the source code as zipped

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

[](#configuration)

1. Import the ussd\_sample.sql file into MySQL database.
2. Configure the database connection using dbConnector.php file

```

```

3. Go to "". Create an account then click on the `Go to Sandbox App` button
4. In your sandbox account under USSD &gt; Create Channel , pick a shared service code such as `*384*` and a channel such as 1100 i.e `*384*1100#` (Be sure to take a unique channel which is not taken already)
5. Configure your callback URL (the URL that points to your application) e.g [http://www.example.com/folder\_name/ussd.php](http://www.example.com/folder_name/ussd.php) then click `Create channel`. This assumes you are working from a live server whose domain name is example.com.Replace the domain name with your own.
6. If working from localhost you can set up a `Ngrok` server or `Localtunnel` to expose your localhost to the internet. Use the temporary URL provided as your callback e.g [http://6a71f5ec.ngrok.io/folder\_name/ussd.php](http://6a71f5ec.ngrok.io/folder_name/ussd.php). This only works when the computer is on and connected to the internet. If using `Ngrok` free package this address may change every 8 hours. You could opt for a paid version at 5 US dollars a month.
7. Go to `Settings > API key` and enter your password to generate an API key. Look for a file named `config.php` and set your username as `sandbox` and the api key as the one you have generated.
8. Configure a payment product (if working with mobile money). Payment products allow you to interact with `Africa's Talking` payment APIs. Go to `Payments > Products` to create a payment product for testing.

### Usage

[](#usage)

```

    $gateway = new AfricasTalkingGateway($username,$apikey,"sandbox");
    $productName  = "SendFunds";
    $currencyCode = "KES";

    $recipient   = array(
        "phoneNumber" => $phoneNumber,
         "currencyCode" => "KES",
        "amount"=> 500,
        "metadata"=>array("name"=> "Basil","reason" => "Funds Transfer")
        );

    $recipients  = array($recipient);

```

9. Configure a an SMS shortcode (if working with SMS). This allows sending of SMS notifications (for this case on sandbox mode). Go to `SMS > Shortcodes > Create Shortcode` to create an SMS shortcode for testing.

### Usage

[](#usage-1)

```

    $code = '20880';
    $recipients = $phoneNumber;
    $message    = "We have sent KES 500 to ".$userResponse." If this is a wrong number the transaction will fail.
    Your new balance is KES ".$newBal.". Thank you.";

    $gateway    = new AfricasTalkingGateway($username, $apikey,"sandbox");

```

10. Now test the USSD application using `Africa's Talking` android app downloaded from Google Playstore or use the web interface at  using the USSD code you configured i.e. `*384*1100#`

API's Supported
---------------

[](#apis-supported)

The code is configure to to work with the `Africa's Talking` API and may support the following payment types

### 1. [C2B](https://developer.safaricom.co.ke/docs#c2b-api)

[](#1-c2b)

####  What it is?

[](#--what-it-is)

This endpoint enables developers to receive real time notifications when a client makes a payments to a merchant's Till number or Paybill number. It assumes the payment are made via the SIM card toolkit and as a developer you need to know when that payment hits the merchants till/paybill number for reconciliation and accounting purposes.

### 2. [B2C](https://developer.safaricom.co.ke/docs#b2c-api)

[](#2-b2c)

####  What it is?

[](#--what-it-is-1)

This endpoints enables merchants to pay their customers from they paybill account. Some of the use cases are but not limited to paying salaries, paying promotions to customers etc.

### 3. [B2B](https://developer.safaricom.co.ke/docs#b2b-api)

[](#3-b2b)

####  What it is?

[](#--what-it-is-2)

This endpoint allows merchants to transfer funds from business to business accounts.

Find out more payment options at

Inspiration
-----------

[](#inspiration)

This package was inspired by the code from Graham Ingokho (JaniKibichi) based on the following project:-

Linux Hosting
-------------

[](#linux-hosting)

If you need VPS or dedicated hosting, please visit this link [Server Host](https://serverhost53.com).

Support
-------

[](#support)

Need support using this package:-

Email  or skype me at `basilndonga`.

If you wish to be added as a contributor to this project let me know. If you wish to buy me a coffee, you can support me on this [link](https://buymeacoffee.com/basilndonga).

If you were inspired by this project, don't forget to follow me on github and on twitter `@basilndonga` as well.

If you wish to engage me as a developer for your project, feel free to contact me

License
-------

[](#license)

This USSD Package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

Happy coding!!!!!!!

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/a8993ca6f1ac8053ec6b092bc7cb5e24d0b2b0195ea0b7e9255a0ba93d8ff84b?d=identicon)[basilndonga](/maintainers/basilndonga)

---

Top Contributors

[![Bascil](https://avatars.githubusercontent.com/u/27825464?v=4)](https://github.com/Bascil "Bascil (27 commits)")

### Embed Badge

![Health badge](/badges/bascil-ussd-mobile-money-php/health.svg)

```
[![Health](https://phpackages.com/badges/bascil-ussd-mobile-money-php/health.svg)](https://phpackages.com/packages/bascil-ussd-mobile-money-php)
```

PHPackages © 2026

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