This service (Lipa na M-Pesa Online) leverages on the powerful retention of the mobile Operator. STK Push allowes Mobile Operators to reach their users through the Push Technology.
STK Push provides customers a chance to purchase items online. Customers select the items they want to pay for and pay with STK Push at the checkout point.
The customer only needs to key in their mobile number and they will receive an STK Push notification on their mobile phone to validate the transaction using their M-PESA PIN. The total cost for the items purchased online is deducted from the customers M-PESA account.
To use service, you will need to provide us with the a Pay bill or Buy Goods number being paid to.
https://api.statum.co.ke/api/v2/mpesa/online
Make payment through your application by making a HTTP POST request to the endpoint above.
In addition to the API standard request headers, the body of the request should contain the following fields:
Parameter | Type | Description | Example |
---|---|---|---|
short_code | String | Organization’s shortcode receiving the transaction; should be registered with us. | 888555 |
phone_number | String | The subscriber's phone number (subscriber making the payment) in international format. | 254721553678 |
amount | String | The amount being transacted in Kenya Shillings. | 2000 |
bill_ref_number | String | A unique id passed by your third party system (optional – only for Pay bill payments). | QWERT |
Sample API request
<?php // credentials from your developer account $consumerKey = "568473daf6614cb196caeb5f8805985f"; $consumerSecret = "5a07f41de16e40e4b08b4001142a5a10"; $auth = base64_encode($consumerKey . ":" . $consumerSecret); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.statum.co.ke/api/v2/mpesa/online', CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS =>'{ "phone_number": "254721553678", "short_code": "709345", "amount": "2000", "bill_ref_number": "QWERT" }', CURLOPT_HTTPHEADER => array( "Authorization: Basic $auth", "Content-Type: application/json" ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
The body of the response will be a JSON object containing the following fields:
Parameter | Type | Description | Example |
---|---|---|---|
status_code | Number | The status code of the transaction. | 200 |
description | String | The status description of the transaction. | Operation successful |
request_id | String | The unique reference number as assigned by the Statum API | 35235f08c981474abd388755ed43a427 |
Sample API response payload
{ "status_code": 200, "description": "Operation successful.", "request_id": "35235f08c981474abd388755ed43a427" }
The Lipa na Mpesa online API sends a notification when a specific event happens. To receive these notifications you need to setup a callback URL on your developer account.
The POST parameters that will be passed will be as follows:
Parameter | Type | Description | Example |
---|---|---|---|
request_id | String | The unique reference number as assigned by the our API | Rw20180307054639H4adfKDJDKQ7H |
result_code | String | The result code of the transaction. | 200 |
result_desc | String | The result description of transaction status. | Processed Successfully |
third_party_trans_id | String | The reference number as assigned by the mobile money provider | HR8584JDJD |
short_code | String | The Paybill number or Till number being paid to | 888555 |
transaction_time | String | The date and time stamp of the transaction | 2017-05-18 18:23:23 |
account_balance | String | The Paybill, Buygoods account balance | 34000.00 |
bill_ref_number | String | The account number as entered by the subscriber. (optional – only for Paybill payments). | QWERT |
phone_number | String | The subscriber's phone number (subscriber making the payment) | 2547*****149 |
customer_name | String | The name of the subscriber who made the payment | John |
amount | String | The transaction amount | 200 |
Sample API result payload
{ "result_code": "200", "result_desc": "Processed Successfully", "request_id": "35235f08c981474abd388755ed43a427", "phone_number": "2547*****149", "customer_name": "James", "amount": "2000", "short_code": "888555", "bill_ref_number": "QWERT", "third_party_trans_id": "HR8584JDJD", "account_balance": "34000.00", "transaction_time": "2017-05-18 18:23:23" }