Skip to main content

Bill Payment via the SDK (Php)

You can use our SDKs in various languages to perform operations with Moala:

In this tutorial, we will present a simple approach to integrate the MOALA SDKs in order to perform a bill payment operation.

Prerequisites​

Before getting started, make sure you have the following:

  • An account on the MOALA portal with the necessary permissions to perform deposits.
  • PHP 7.2 or higher
  • Composer to manage dependencies
  • The SDK downloaded and integrated from: Moala Php SDK

Installation​

You can install the SDK via Composer.
Add the SDK to your project using the following command:

composer require bitkap/php-moala

1. Authentication​

Authentication with the Moala SDK is done by configuring the SDK client with your API key and secret key.

use MoalaSDK\MoalaClient;

$base_url = "https://api.moala.africa";
$appKey = "your_app_key";
$secretKey = "your_secret_key";

$client = new MoalaClient($base_url, $appKey, $secretKey);

2. Make the Payment​

We will now perform a bill payment operation using the MOALA SDK.

$payment = $client->cashout($phoneNumber, $serviceCode, $amount, $partnerId);
print_r($payment);
info

The allowed serviceCode values are:

  • CASHOUT_MTN_CM: Cashout MTN Cameroon
  • CASHOUT_ORANGE_CM: Cashout Orange Cameroon
  • CASHOUT_AIRTEL_GA: Cashout Airtel Gabon
  • CASHOUT_MOOV_GA: Cashout Moov Gabon
  • PAIEMENTMARCHAND_MTN_CM: Merchant Payment MTN Cameroon
  • PAIEMENTMARCHAND_ORANGE_CM: Merchant Payment Orange Cameroon
  • PAIEMENTMARCHAND_AIRTEL_GA: Merchant Payment Airtel Gabon
  • PAIEMENTMARCHAND_MOOV_GA: Merchant Payment Moov Gabon
warning

The partnerId field must be unique for each transaction, otherwise the request will fail.

3. Check the Deposit Status​

Once the deposit request has been sent, you can check the success of the operation by making another SDK method call.

$status = $client->checkTransaction($partnerId);
print_r($status);

4. Run the Code​

Now let's run the code presented above.

We will try to make a 500F deposit from an Orange Money number.

use MoalaSDK\MoalaClient;

$base_url = "https://api.moala.africa";
$appKey = "your_app_key";
$secretKey = "your_secret_key";

// Authentication
$client = new MoalaClient($base_url, $appKey, $secretKey);

// Execute payment
$serviceCode = "CASHOUT_ORANGE_CM";
$phoneNumber = "XXXXXXXXX";
$partnerId = "xxxxxxxx";
$amount = 1000;
$payment = $client->cashout($phoneNumber, $serviceCode, $amount, $partnerId);
print_r($payment);

// Check payment status
$status = $client->checkTransaction($partnerId);
print_r($status);

5. Conclusion​

By the end of this tutorial, you now know how to integrate MOALA APIs to perform a bill payment operation.