Photo by Sai Kiran Anagani on Unsplash
How to Integrate to Zamtel Mobile money Pay Bill(Rest API )
introduction
Zamtel Mobile money is one of the 3 Mobile network services providers MNOs in Zambia. Zamtel offers pay-bill API services among many other services. in this article, we shall concentrate on how to integrate into zamtel mobile money using a pay bill service.
How it Works
Here are my basics understanding of how the zamtel mobile money pay bill API works customers visit a website or mobile app, he initials a checkout for a product or service, customer select zamtel mobile money a as a payment method customer checkout a merchant or organization initiates a checkout to zamtel system. When zamtel receives the request from the merchants, it initiates a USSD push to the customer for confirmation of the payment, Customer responds to the USSD push by entering their mobile money pin. the response of the transaction is later forwarded to the merchant(initiator of the transaction). Note: The scenario above is asynchronous request.
Currency is ZMW
Requirements
Just not to waste much of your time below are the requirement to make a successful call to zamtel mobile API.
- Zamtel MSISDN (phone number ). it a dynamic values and changes based on which customer to be debited.
Third-party Id: this will be shared by zamtel and is always static
password: this will be shared by zamtel and is always static
Shortcode also called a merchant code: this is a unique identifier, that makes your organization or account unique on the mobile money platform this param Is always static
ConversationId : is a param field that contains a unique value passed from your system. examples of unique values can be order Id, transaction id from yours or any service number from your system. below is a basic illustration on postman.
Code Snippet
let's look at a simple PHP Curl request. I decided to use PHP because of the 2 things I think about when using PHP to integrate. firstly I believe PHP is a language from the gods! and secondly, if it works in PHP then it can work in any language many will argue but we all have different opinions ๐ ๐
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://{BASEURL}ThirdPartyID=&Password=&Amount=1&Shortcode=000165&ConversationId=12552&Msisdn=26095000000&ConversationId=xx87sxc232',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
The Base Url will be shared once the other credentials have been shared
Let's have a look at the some of the common responses on the playbill API
Wrong Pin
{
"status": "2006",
"transaction_id": "",
"amount": "10",
"message": "Balance insufficient.",
"reference": "1234"
}
Insufficient Balance
{
"status": "2006",
"transaction_id": "",
"amount": "10",
"message": "Balance insufficient.",
"reference": "1234"
}
Service Unavailable
{
"status": "E8039",
"transaction_id": "",
"amount": "10",
"message": "Service not avaiable",
"reference": "1234"
}
Timeouts
{
"status": "-1",
"transaction_id": "",
"amount": "10",
"message": "System internal error.",
"reference": "1234"
}
Wrong Params
{
"status": "E8027",
"transaction_id": "",
"amount": "10",
"message": "System is unable to process your request now, please try later.",
"reference": "1234"
}
The API returns a String of JSON method
Conclusion
The checkout or bill payment API is readily available once commercial documentation has been processed by the zamtel commercial team. Therefore, we can simply say that integrating to zamtel API is as easy as declaring a variable in python.
if you would like to know more information about zamtel mobile money you can access it here.