mazzuma 0.0.1

Mazzuma mobile money payment API

To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

Mazzuma Mobile Payment API

This is an unofficial Mazzuma API for Mobile Money payment written in D. It's also available as a package in the Dub package registry.


Using Dub, you may add mazzuma as dependency in your dub.json file and the package will be downloaded automatically during project build if it's not downloaded already.

    "dependencies": {
        "mazzuma": "~>0.0.1"

You may also fetch the latest version manually in the command-line:

dub fetch mazzuma

API configuration

The mazzuma.config.Config struct is used to configure merchant (receiver) phone number and API key. Substitute information provided below with your own account information. Check the Mazzuma API Documentation for more infomation.

From a security standpoint, it much safer to store your merhcant account API keys and other confidential information in environment variables instead of hard-coding them in your source code.

import std.stdio : writeln;
import std.conv : to;

import mazzuma : MobileMoney, Config;

void main()

    auto config = Config("YOUR_MERCHANT_PHONE_NUMBER", "YOUR_API_KEY");
    MobileMoney pay = MobileMoney(config);

    // Sending payment to your merchant account
    auto sendResult = pay.send("0247575773", 50.20);

    if (sendResult.error)
        //Most likely a network failure
        string errorMessage = sendResult.response;
        writeln("Failed to submit payment: ", sendResult.response);

        //Connection went through. Use response 
        // (JSON string or null) 
        // to determine if payment actually succeeded

        import std.json : JSONValue;

        auto jsonReponse = JSONValue(sendResult.response);
        writeln("Response as JSON: ", jsonReponse);

        // when a mazzuma errors occures, it returns "null"
        // Currently it's a blackbox with no way of 
        // knowing exactly what happened ATM.
        if (jsonReponse.isNull)
                    "Payment failed, check your balnace or make sure your phone is on approved payment request.");

        // Mazzuma returns {"code":1,"status":"success","id":"XXXXX"} for successful payment
        if (!int == 1)
            writeln("Payment received ;).");

        // Mazzuma returns {"code":200,"id":"XXXXX","status":"Successful"} for 
        // pending payment i.e. Tigo Cash, you 
        // have to poll continously to get final status
        // using "id" parameter in the JSON response
        // [That sucks, right? ...Yep I know. Mazzuma says 
        // its due to the way Tigo Cash works]
        // Confirm current status at
        if (!int == 200)
                    "Payment stattuc pending. Please poll<id>");


  • Add test coverage
    • contract for send()
    • API call response
    • Config()
  • Improve API documentation
  • Lawrence Aberba
0.0.1 2018-May-07
~master 2018-May-07
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 11 downloads total

Short URL: