Appearance
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}| Auth | Secret key, Authorization: Bearer mkp_… |
| Scope | charges:write |
| Who can read | The 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 flag | Registered only where direct charges are on |
Headers
| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer mkp_test_… or Bearer mkp_live_… |
Parameters
Path
| Name | Type | Required | Constraints and meaning |
|---|---|---|---|
id | string | Yes | The 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": nullResponse fields
data is the charge object.
| Field | Type | Meaning |
|---|---|---|
status | string | pending, succeeded, failed, expired or cancelled |
next_action | object or null | While pending only. A card charge's has no client_secret here |
failure | object or null | { code, message } once failed, and on an expired card charge the last decline |
receipt_number | string or null | The 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
| HTTP | Code | Name | When | What to do |
|---|---|---|---|---|
400 | 1701 | INVALID_REQUEST_DATA | The id is longer than 64 characters | Check the id |
400 | 3014 | IDENTITY_HEADER_REFUSED | The request carries a session or identity header | Remove the header |
401 | 2781 | API_KEY_INVALID | Missing, malformed, unknown or revoked key | Check the key |
403 | 2941 | API_KEY_SCOPE_REQUIRED | The key lacks charges:write | Issue a key with the scope |
403 | 3042 | API_KEY_IP_NOT_ALLOWED | The account has allowed addresses and the call came from another address | Call from a listed address |
404 | 3001 | CHARGE_NOT_FOUND | No such charge, or one you cannot see. The two are not told apart | Check the id |
429 | 1804 | RATE_LIMIT_EXCEEDED | Over the rate limit | Wait Retry-After seconds |
503 | 2782 | AUTHN_UNAVAILABLE | Keys cannot be checked | Retry 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.