POST: MPESA STK STATUS

Use this endpoint to query for the status of a C2B transaction that was initiated.

Query Status

POST https://payherokenya.com/intasend/stk_status

Transaction response returns a field labeled invoice_id. We use invoice_id to check for the status of the transaction.

Below are code examples for transaction status querying using the invoice_id.

Body

NameTypeDescription
api_username

string

Your Pay Hero API Key username

invoice_id

number

Your transaction invoice_id

Response

{
    "invoice": {
        "invoice_id": "0XND4EY",
        "state": "PENDING",
        "provider": "M-PESA",
        "charges": 0,
        "net_amount": "52.00",
        "currency": "KES",
        "value": 52,
        "account": "254767677678",
        "api_ref": "test3636363",
        "mpesa_reference": null,
        "host": "69.191.111.180",
        "card_info": {
            "bin_country": null,
            "card_type": null
        },
        "retry_count": 0,
        "failed_reason": null,
        "failed_code": null,
        "failed_code_link": null,
        "created_at": "2024-09-10T12:29:08.177832+03:00",
        "updated_at": "2024-09-10T12:29:08.189260+03:00",
        "id": "0XND4EY"
    },
    "meta": {
        "id": "82d08eb4-3a24-46d7-8d08-5acaa0f37d9d",
        "customer": {
            "customer_id": "Y79V27K",
            "phone_number": "254767677678",
            "email": null,
            "first_name": "null",
            "last_name": "null",
            "country": null,
            "zipcode": null,
            "provider": "M-PESA",
            "created_at": "2024-02-09T23:12:37.719303+03:00",
            "updated_at": "2024-08-31T17:45:52.608420+03:00"
        },
        "payment_link": null,
        "customer_comment": null,
        "created_at": "2024-09-10T12:29:08.228217+03:00",
        "updated_at": "2024-09-10T12:29:08.228236+03:00"
    }
}

Sample Request Code: PHP

<?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://payherokenya.com/intasend/stk_status',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "api_username": "323wewewewe",
    "invoice_id": "0XND4Ex"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

Last updated