Skip to content

Retrieve a refund ​

Reads one refund on your account, as it stands now. It returns refunds asked for through the API and in the hub alike.

Endpoint ​

GET /v1/payments/merchant/refunds/{id}
AuthSecret key
Scoperefunds:write
Switched onPer deployment (REFUND_API_ENABLED). Where it is off, the route answers 404

Headers ​

HeaderRequiredValue
AuthorizationYesBearer mkp_…

Parameters ​

Path

NameTypeRequiredConstraints
idstringYesThe refund's id, rf_ and 24 hex characters

Example request ​

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

const res = await fetch(`${BASE}/refunds/rf_5b1e8c2d7a4f90b3e6a1c2d8`, {
  headers: { Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}` },
});
const answer = await res.json();
if (!answer.ok) throw new Error(`${res.status} ${answer.code}: ${answer.description}`);
console.log(answer.data.status, answer.data.decline_reason);
python
import os

import requests

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

res = requests.get(
    f"{BASE}/refunds/rf_5b1e8c2d7a4f90b3e6a1c2d8",
    headers={"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}"},
    timeout=15,
)
answer = res.json()
if not answer["ok"]:
    raise RuntimeError(f"{res.status_code} {answer['code']}: {answer['description']}")
print(answer["data"]["status"], answer["data"]["decline_reason"])
php
<?php
$base = 'https://payments-ke-staging.mookhpay.co/v1/payments/merchant';

$ch = curl_init("$base/refunds/rf_5b1e8c2d7a4f90b3e6a1c2d8");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
    CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('MOOKHPAY_SECRET_KEY')],
]);
$answer = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if (!$answer['ok']) {
    throw new RuntimeException("$status {$answer['code']}: {$answer['description']}");
}
echo $answer['data']['status'], PHP_EOL;

Response ​

200 OK with description Refund.

json
{
  "ok": true,
  "description": "Refund",
  "data": {
    "id": "rf_5b1e8c2d7a4f90b3e6a1c2d8",
    "status": "declined",
    "amount": 50000,
    "fee": 0,
    "currency": "KES",
    "reason": "One latte was not served",
    "decline_reason": "The payer has already been refunded by the shop directly.",
    "checkout_id": "cs_ke_3f9a1c7e5b2d4a8e6c0b91d7",
    "charge_id": null,
    "intent_id": "pi_8c1e4f0a7b3d92e5a6f01c48",
    "reference": "order-1042",
    "provider_receipt": null,
    "method": null,
    "requested_via": "api",
    "requested_at": "2026-11-21T07:40:12.000Z",
    "reviewed_at": "2026-11-21T07:58:30.000Z",
    "refunded_at": null
  }
}

Response fields ​

data is the refund object.

Errors ​

HTTPCodeNameWhenWhat to do
4003014IDENTITY_HEADER_REFUSEDThe request carries a session or identity headerRemove it
4012781API_KEY_INVALIDMissing, malformed, unknown or revoked keyCheck the key
4032941API_KEY_SCOPE_REQUIREDThe key lacks refunds:writeHave an Owner replace the key with one that has it
4033042API_KEY_IP_NOT_ALLOWEDThe account has allowed addresses and the call came from another addressCall from a listed address
4042864REFUND_REQUEST_NOT_FOUNDNo refund by that id on your account. Another account's refund answers the sameCheck the id
4291804RATE_LIMIT_EXCEEDEDOver the rate limit belowWait Retry-After seconds
5032782AUTHN_UNAVAILABLEThe key could not be checkedRetry

Rate limit ​

120 requests a minute per account, shared by the three refund routes. Over it: 429, code 1804, with Retry-After and data.retryAfter in seconds.

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