Skip to main content

Integration Examples

This guide outlines the steps required to integrate MOALA’s SDKs and REST APIs into your application.

SDK Integration​

MOALA has developed ready-to-use SDKs to simplify the integration of its platform. These SDKs support several operations, such as: balance check, transaction history, KYC compliance check, deposit, withdrawal, etc.

We provide SDKs in 3 programming languages:

info

To use the SDKs described below, you need to have an account on our back office.

This account is created once you have completed all the administrative steps described in the previous section Prerequisites and integration procedures

Prerequisites​

  • Java 8 or higher
  • Maven for dependency management

Installation​

You can install the SDK via Maven.

<dependency>
<groupId>africa.moala</groupId>
<artifactId>sdkmoala</artifactId>
<version>1.0</version>
</dependency>

Add the SDK to your project using the command :

mvn package

Configuration​

To use the SDK, you need an API key provided by MOALA. Here’s how to use it to initialize the SDK :

import africa.moala;

String urlApi = "https://api.moala.africa";
String appKey = "your_app_key";
String secretKey = "your_secret_key";

MoalaClient moalaClient = new MoalaClient(appKey, secretKey, urlApi);

Usage​

Balance Check​

double res = moalaClient.getBalance();
System.out.println(res);

Transaction Verification​

TransactionView transactionView = moalaClient.checkTransaction("partnerId");
System.out.println(transactionView);

KYC Verification​

KycView kycView = moalaClient.getKycNumber("phoneNumber","serviceCode");
System.out.println(kycView);

Make a Deposit​

TransactionView transactionView = moalaClient.cashin("phoneNumber","serviceCode",amount, "partnerId");
System.out.println(transactionView);

Make a withdrawal​

TransactionView transactionView = moalaClient.cashout("phoneNumber","serviceCode",amount, "partnerId");
System.out.println(transactionView);

REST API Integration​

MOALA’s API is a standard REST API that can be integrated into any backend. Only a few minor configurations are needed to start using it.

Header Configuration​

MOALA’s API requires 3 mandatory headers to be added :

  • LP-ACCESS-KEY: API Key available in the MOALA Portal Portail MOALA
  • LP-ACCESS-TIMESTAMP: epoch time in seconds
  • LP-ACCESS-SIGN: the digital signature or API Secret Key that you generate

Signature Generation​

The signature format is as follows: LP-ACCESS-TIMESTAMP + requestMethod + pathRequest + body (in JSON)

The resulting string must then be signed using the API key obtained from the admin portal, with the HMAC-SHA256 HEX algorithm

API Get Balance​

// Java - Récupération du solde
String message = "1718193158GET/v1/api/balance";
String secret_key = "your_secret_key";

String signatureSyn = HmacUtils.hmacSha256Hex(secret_key, message);

API CashIn Orange Money​

// Java - Cashin Orange Money
String message = "1718199502POST/v1/api/transaction/withdrawal{\"transactionType\":\"withdrawal\",\"amount\":100,\"serviceCode\":\"CASHIN_MTN_CM\",\"phoneNumber\":\"675598817\",\"partnerId\":\"tst_13\"}";
String secret_key = "your_secret_key";

String signatureSyn = HmacUtils.hmacSha256Hex(secret_key, message);
info

The available Service Codes for API calls are :

  • CASHIN_MTN_CM: cashin MTN Cameroon
  • CASHIN_ORANGE_CM: cashin Orange Cameroon
  • CASHIN_AIRTEL_GA: cashin Airtel Gabon
  • PAIEMENTMARCHAND_AIRTEL_GA: Merchant payment Airtel Gabon
  • PAIEMENTMARCHAND_ORANGE_CM: Merchant payment Orange Cameroun
  • PAIEMENTMARCHAND_MTN_CM: Merchant payment MTN Cameroun

Error Handling​

Each SDK method may raise exceptions in case of an error, and the API endpoints may return error codes.

Support​

If you have questions or face difficulties integrating our APIs, you can open a support ticket here: GitHub repository GitHub repository.