Skip to content

Retrieve a charge ​

Reads one charge as it is now. Reading a charge also moves it on: a charge past its expires_at is marked expired on the read, and one whose payment has been booked is marked succeeded.

A read never answers the client_secret of a card charge. That is only in the create answer and its idempotent repeat.

Endpoint ​

GET /v1/payments/merchant/charges/{id}
AuthSecret key, Authorization: Bearer mkp_…
Scopecharges:write
Who can readThe payee reads its own charges, including those a platform made on its behalf. A platform reads the charges it made. Anybody else gets 404
Feature flagRegistered only where direct charges are on

Headers ​

HeaderRequiredValue
AuthorizationYesBearer mkp_test_… or Bearer mkp_live_…

Parameters ​

Path ​

NameTypeRequiredConstraints and meaning
idstringYesThe charge id, ch_<country>_<24 hex>. 1 to 64 characters (a longer one is 400 1701); anything that is not a charge you can see is 404

Example request ​

Poll every two seconds while status is pending, and stop at next_action.expires_at.

sh
curl https://payments-ke-staging.mookhpay.co/v1/payments/merchant/charges/ch_ke_7e1a4c9b2d5f80e3a6c1b047 \
  -H "Authorization: Bearer $MOOKHPAY_SECRET_KEY"
js
const BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";

async function waitForCharge(id) {
  for (;;) {
    const res = await fetch(`${BASE}/charges/${id}`, {
      headers: { Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}` },
    });
    const body = await res.json();
    if (!body.ok) throw new Error(`${res.status} ${body.code}: ${body.description}`);
    if (body.data.status !== "pending") return body.data;
    await new Promise((resolve) => setTimeout(resolve, 2000));
  }
}

const charge = await waitForCharge("ch_ke_7e1a4c9b2d5f80e3a6c1b047");
console.log(charge.status, charge.failure?.code ?? charge.receipt_number);
python
import os
import time
import requests

BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant"


def wait_for_charge(charge_id):
    while True:
        res = requests.get(
            f"{BASE}/charges/{charge_id}",
            headers={"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}"},
            timeout=30,
        )
        body = res.json()
        if not body["ok"]:
            raise RuntimeError(f"{res.status_code} {body['code']}: {body['description']}")
        if body["data"]["status"] != "pending":
            return body["data"]
        time.sleep(2)


charge = wait_for_charge("ch_ke_7e1a4c9b2d5f80e3a6c1b047")
print(charge["status"], (charge["failure"] or {}).get("code") or charge["receipt_number"])
php
<?php
$base = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";

function readCharge(string $base, string $id): array
{
    $ch = curl_init("$base/charges/$id");
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("MOOKHPAY_SECRET_KEY")],
    ]);
    $body = json_decode(curl_exec($ch), true);
    $status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
    curl_close($ch);
    if (!$body["ok"]) {
        throw new RuntimeException("$status {$body['code']}: {$body['description']}");
    }
    return $body["data"];
}

do {
    $charge = readCharge($base, "ch_ke_7e1a4c9b2d5f80e3a6c1b047");
    if ($charge["status"] === "pending") {
        sleep(2);
    }
} while ($charge["status"] === "pending");

echo $charge["status"], " ", $charge["failure"]["code"] ?? $charge["receipt_number"], PHP_EOL;

Response ​

200 OK. A charge that succeeded:

json
{
  "ok": true,
  "description": "Charge",
  "data": {
    "id": "ch_ke_7e1a4c9b2d5f80e3a6c1b047",
    "status": "succeeded",
    "test": false,
    "amount": 150000,
    "currency": "KES",
    "fee": 0,
    "net": 150000,
    "reference": "order-8841",
    "description": "A3 print",
    "payment_method": { "type": "mobile_money", "rail": "mpesa", "phone": "+254 7•• ••• 678" },
    "next_action": null,
    "failure": null,
    "receipt_number": "TKL4XQ2B9M",
    "hosted_url": "https://mookhpay.co/checkout/cs_ke_0b4d2f7a9c1e53b8d6a2e410",
    "metadata": { "till": "4" },
    "expires_at": "2026-11-20T09:20:00.000Z",
    "created_at": "2026-11-20T09:14:00.000Z"
  }
}

A charge that failed carries failure:

json
"status": "failed",
"failure": { "code": "insufficient_funds", "message": "The payer did not have enough money for this payment" },
"receipt_number": null

Response fields ​

data is the charge object.

FieldTypeMeaning
statusstringpending, succeeded, failed, expired or cancelled
next_actionobject or nullWhile pending only. A card charge's has no client_secret here
failureobject or null{ code, message } once failed, and on an expired card charge the last decline
receipt_numberstring or nullThe rail's receipt once succeeded, where the rail gives one

succeeded is set only once the payment is booked, the moment payment.succeeded is sent. A charge that expired or was cancelled while a prompt was already on the payer's phone, and is then approved, still moves to succeeded. Keep checking after expires_at for that case, or trust the webhook.

Errors ​

HTTPCodeNameWhenWhat to do
4001701INVALID_REQUEST_DATAThe id is longer than 64 charactersCheck the id
4003014IDENTITY_HEADER_REFUSEDThe request carries a session or identity headerRemove the header
4012781API_KEY_INVALIDMissing, malformed, unknown or revoked keyCheck the key
4032941API_KEY_SCOPE_REQUIREDThe key lacks charges:writeIssue a key with the scope
4033042API_KEY_IP_NOT_ALLOWEDThe account has allowed addresses and the call came from another addressCall from a listed address
4043001CHARGE_NOT_FOUNDNo such charge, or one you cannot see. The two are not told apartCheck the id
4291804RATE_LIMIT_EXCEEDEDOver the rate limitWait Retry-After seconds
5032782AUTHN_UNAVAILABLEKeys cannot be checkedRetry with backoff

Rate limit ​

120 requests a minute per key owner, one bucket shared with List charges for a reference, Cancel a charge, Create a checkout and Retrieve a checkout. Polling one charge every two seconds uses 30 a minute. Over it: 429, code 1804, Retry-After in seconds.

Staging documentation. A checkout made with a secret key on staging charges a real phone. See Environments.