Mpesa Query API
Tips
- All requests are
Postrequests, and the data format isjson
Brief Description
- Check transaction results by MPESA transaction codes
Request URL
/api/queryResultByCode
Request Method
- Post
Header
| Name | required | type | desc |
|---|---|---|---|
| merchantNo | Yes | string | - |
Body
| Name | required | type | desc |
|---|---|---|---|
| code | Yes | string | MPESA transaction codes |
| timestamp | Yes | string | Timestamp (1715941383720) |
| sign | Yes | string | Except for the sign field, all remaining fields should be sorted alphabetically by their first letter, combined into key1=value1key2=value2, and encrypted using the app secret as salt via MD5. The final sign value should be in lowercase. |
Request Parameter Example
{
"code": "SHL2A6WAQU",
"timestamp":"2222222222",
"sign": "000000000"
}
Response Result
| Name | required | type | desc |
|---|---|---|---|
| msg | Yes | string | Request result (when returning success, it only indicates that the request was successful and cannot be used for merchant-side logic judgment) |
| code | Yes | string | Request response code (when returning 0000, it only indicates that the request was successful and cannot be used for merchant-side logic judgment). For specific error codes, please refer to the business error code enumeration. |
| timestamp | Yes | string | Transaction time |
| success | Yes | string | Transaction result |
| data | Yes | Object | Return object |
| data.platFormTradeNo | Yes | string | MPESA transaction codes |
| data.amount | Yes | string | transaction amount |
| data.status | Yes | string | Request result, merchants can use this for logic processing. When the result is 0000, it indicates a successful transaction; 0015 indicates processing; all other codes indicate errors and can be treated as failures. |
| data.message | Yes | string | Error description |
| data.mpesaReceiptNumber | Yes | string | MPESA transaction codes |
| data.successTime | Yes | string | Transaction success time (Kenya time) |
{
"msg": "success",
"code": "0000",
"timestamp": 1719830071094,
"success": true,
"data": {
"platFormTradeNo": "5286e98841194687a95d25b5f3be346d",
"tradeNo": "00000020",
"amount": 3.0000,
"status": "00029",
"mpesaReceiptNumber": "SHL2S6WAAU",
"message": "REJECTED_TRANSACTION",
"successTime": "2024-07-01 18:34:31"
}
}
