Appearance
Direct charges
A direct charge takes a payment from your server while the payer stays on your own screen. There is no redirect. For mobile money, one call creates the payment and sends the prompt to the payer's phone at once. For M-Pesa Pay Bill, the call answers the numbers to show the payer. For a card, it answers a secret for the card element on your page.
Underneath, a charge is a checkout and its payment attempt. Booking, receipts, Pay Bill matching, the test numbers and the payment.* webhooks work as they do for a hosted checkout.
Charge or hosted checkout
| Direct charge | Hosted checkout | |
|---|---|---|
| The payer | Stays in your app or site | Goes to MOOKHPay's page, then back |
| You build | The screen that asks for the number and waits | Nothing beyond a redirect |
| Ways to pay | Mobile money prompt, M-Pesa Pay Bill, card through the card element | Mobile money, Pay Bill, card, MOOKHPay balance |
| A failed prompt | Ends the charge. Create a new one to try again | The payer tries again on the same checkout |
| Scope | charges:write | checkouts |
| Test mode | Every charge from a staging key (mkp_test_) is a test charge | None for a secret key |
Every charge also has a hosted_url: the same payment on the hosted page. Give it to the payer if the prompt does not arrive.
Get a key with charges:write
A key made with no choice of scopes does not have charges:write. In an organisation only an Owner can be issued one: the Owner chooses Direct Charges (charges:write) on Create A Key or Replace Key in the hub, along with any other scopes the integration uses, and enters their PIN. Replacing a key keeps the old one working for 24 hours, so you can deploy the new key first. See API keys and scopes.
A key without the scope answers 403 and code 2941.
Create a mobile-money charge
Call POST /charges with an Idempotency-Key. The prompt goes to phone before the answer comes back.
sh
curl -X POST https://payments-ke-staging.mookhpay.co/v1/payments/merchant/charges \
-H "Authorization: Bearer $MOOKHPAY_SECRET_KEY" \
-H "Idempotency-Key: order-8841-1" \
-H "Content-Type: application/json" \
-d '{
"amount": 150000,
"reference": "order-8841",
"description": "Order 8841",
"payment_method": { "type": "mobile_money", "phone": "+254700000000" },
"payer_email": "[email protected]",
"metadata": { "cart": "8841", "channel": "pos" }
}'js
const API = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
const res = await fetch(`${API}/charges`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}`,
"Idempotency-Key": "order-8841-1",
"Content-Type": "application/json",
},
body: JSON.stringify({
amount: 150000,
reference: "order-8841",
description: "Order 8841",
payment_method: { type: "mobile_money", phone: "+254700000000" },
payer_email: "[email protected]",
metadata: { cart: "8841", channel: "pos" },
}),
});
const body = await res.json();
if (!body.ok) throw new Error(`${body.code}: ${body.description}`);
console.log(body.data.id, body.data.next_action);python
import os
import requests
API = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant"
res = requests.post(
f"{API}/charges",
headers={
"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}",
"Idempotency-Key": "order-8841-1",
},
json={
"amount": 150000,
"reference": "order-8841",
"description": "Order 8841",
"payment_method": {"type": "mobile_money", "phone": "+254700000000"},
"payer_email": "[email protected]",
"metadata": {"cart": "8841", "channel": "pos"},
},
timeout=30,
)
body = res.json()
if not body["ok"]:
raise RuntimeError(f"{body['code']}: {body['description']}")
print(body["data"]["id"], body["data"]["next_action"])php
<?php
$api = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
$ch = curl_init("$api/charges");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("MOOKHPAY_SECRET_KEY"),
"Idempotency-Key: order-8841-1",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"amount" => 150000,
"reference" => "order-8841",
"description" => "Order 8841",
"payment_method" => ["type" => "mobile_money", "phone" => "+254700000000"],
"payer_email" => "[email protected]",
"metadata" => ["cart" => "8841", "channel" => "pos"],
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);
if (!$body["ok"]) {
throw new RuntimeException($body["code"] . ": " . $body["description"]);
}
echo $body["data"]["id"], "\n";+254700000000 is a test number: on a staging key it succeeds after about 3 seconds with no prompt. On a production key, use the payer's real number.
The answer is 201:
json
{
"ok": true,
"description": "Charge created",
"data": {
"id": "ch_ke_8a3f0c2d9b1e4f5a6c7d8e9f",
"status": "pending",
"test": true,
"amount": 150000,
"currency": "KES",
"fee": 0,
"net": 150000,
"reference": "order-8841",
"description": "Order 8841",
"payment_method": { "type": "mobile_money", "rail": "mpesa", "phone": "+254 7•• ••• 000" },
"next_action": {
"type": "await_payer",
"expires_at": "2026-11-20T10:06:00.000Z",
"display": "Enter your M-Pesa PIN on your phone"
},
"failure": null,
"receipt_number": null,
"hosted_url": "https://mookhpay.co/checkout/cs_ke_1b2c3d4e5f6a7b8c9d0e1f2a",
"metadata": { "cart": "8841", "channel": "pos" },
"expires_at": "2026-11-20T10:06:00.000Z",
"created_at": "2026-11-20T10:00:00.000Z"
}
}Charge amounts are numbers, unlike a checkout's strings. The phone comes back masked to its first four and last three digits.
What you can send
Unknown fields are refused with 400 and code 1701, at the top level and inside payment_method.
| Field | Type | Required | Rules |
|---|---|---|---|
amount | integer | Yes | Minor units, 1 to 100,000,000,000, and inside the rail's collection limits (KES 1 to KES 150,000 on M-Pesa; UGX 1 to UGX 5,000,000 in whole shillings on MTN MoMo). Outside them: 422 and code 2702 |
reference | string | Yes | Your order id, 1 to 64 characters. One pending charge per reference at a time |
description | string | No | 1 to 140 characters. Shown on the hosted page at hosted_url |
payment_method | object | Yes | One of the three shapes below |
payer_email | string | No | Up to 254 characters, for the payer's receipt. mobile_money and card only; with paybill it answers 400 and code 1701. A malformed address answers 400 and code 1701 |
metadata | object | No | Up to 20 pairs. Keys 1 to 40 characters, values strings of up to 500 characters. Comes back on every read and on the webhooks |
on_behalf_of, platform_fee | No | Platforms only. See Take payments with a fee |
payment_method | Fields |
|---|---|
{ "type": "mobile_money", "phone": "…" } | phone: the payer's number with its country code, + optional, such as +254712345678. It must be a number the deployment's rail can prompt: 254 and 9 digits on M-Pesa, 256 and 9 digits on MTN MoMo, otherwise 400 and code 1701. Optional rail: mpesa or momo. A rail this deployment does not run answers 422 and code 2701 |
{ "type": "paybill" } | Nothing else. Kenya only, where Pay Bill is on, and never on a staging key. Elsewhere 400 and code 3004 |
{ "type": "card" } | Nothing else. Production keys only, where cards are on. See Card payments |
Create a Pay Bill charge
A paybill charge sends no prompt. It answers a Pay Bill number and an account number for the payer to pay from the M-Pesa menu. It is offered on Kenya with a production key, where Pay Bill is switched on.
sh
curl -X POST https://payments-ke-staging.mookhpay.co/v1/payments/merchant/charges \
-H "Authorization: Bearer $MOOKHPAY_SECRET_KEY" \
-H "Idempotency-Key: order-8842-1" \
-H "Content-Type: application/json" \
-d '{
"amount": 250000,
"reference": "order-8842",
"payment_method": { "type": "paybill" }
}'js
const API = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
const res = await fetch(`${API}/charges`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}`,
"Idempotency-Key": "order-8842-1",
"Content-Type": "application/json",
},
body: JSON.stringify({
amount: 250000,
reference: "order-8842",
payment_method: { type: "paybill" },
}),
});
const { ok, data, code, description } = await res.json();
if (!ok) throw new Error(`${code}: ${description}`);
const { business_number, account_number, amount } = data.next_action;
console.log(`Pay Bill ${business_number}, account ${account_number}, KES ${amount / 100}`);python
import os
import requests
API = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant"
res = requests.post(
f"{API}/charges",
headers={
"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}",
"Idempotency-Key": "order-8842-1",
},
json={
"amount": 250000,
"reference": "order-8842",
"payment_method": {"type": "paybill"},
},
timeout=30,
)
body = res.json()
if not body["ok"]:
raise RuntimeError(f"{body['code']}: {body['description']}")
action = body["data"]["next_action"]
print(f"Pay Bill {action['business_number']}, account {action['account_number']}, KES {action['amount'] / 100:.2f}")php
<?php
$api = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
$ch = curl_init("$api/charges");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("MOOKHPAY_SECRET_KEY"),
"Idempotency-Key: order-8842-1",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"amount" => 250000,
"reference" => "order-8842",
"payment_method" => ["type" => "paybill"],
]),
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);
if (!$body["ok"]) {
throw new RuntimeException($body["code"] . ": " . $body["description"]);
}
$action = $body["data"]["next_action"];
printf("Pay Bill %s, account %s, KES %.2f\n", $action["business_number"], $action["account_number"], $action["amount"] / 100);On a staging key this call answers 400 and code 3004, because a staging key makes test charges and test charges are mobile money only.
The payer must pay the exact amount. A different amount still lands in your main wallet as an ordinary payment, but it does not pay the charge, and you reconcile it yourself.
Card charges
{ "type": "card" } answers next_action.type use_card_element with a client_secret. Your server hands the secret to your checkout page, and the card element (mookhpay.js) takes the card there, so card numbers never reach your server. The page must be on the list of origins an Owner saved for card payments.
- Card charges are refused with
400and code3004on a staging key (mkp_test_), and wherever cards are not switched on. They cannot be tested end to end on staging. - A card charge stays
pendingfor the card attempt's life: 30 minutes by default (CARD_UC_INTENT_TTL_SECONDS). - A declined card leaves the charge
pending, so the payer can try another card. If it expires,failurecarries the last decline (ornull), andpayment.failedfollows only when the element had opened a card attempt and nothing is still in flight. - The payer pays the amount plus a card fee; you receive the amount.
next_action.feeandnext_action.totalgive both.
The whole flow is in Card payments.
Lifecycle
status | Meaning | Do this |
|---|---|---|
pending | Waiting for the payer | Show next_action and wait |
succeeded | The money is booked | Fulfil once |
failed | The payer or the rail refused. failure says why | Tell the payer. Offer a new charge |
expired | No answer by expires_at | Offer a new charge, or hosted_url |
cancelled | You cancelled it | Nothing |
succeeded is set only once the ledger booking is done, which is the moment payment.succeeded is sent. A charge never leaves succeeded.
A charge that ended can still become succeeded. A prompt already on the payer's phone cannot be recalled, and a Pay Bill payment can arrive after the window. When such a payment is booked, the charge moves to succeeded and payment.succeeded is sent. MOOKHPay sweeps for these for 7 days after a charge was due to end, and every read of a charge checks again. Do not fulfil on expired, failed or cancelled, and keep listening for payment.succeeded on those charges.
How long a charge stays pending:
payment_method | expires_at by default |
|---|---|
mobile_money | 6 minutes: the prompt's life (INTENT_TTL_SECONDS, 300) and a grace period (CHARGE_PROMPT_GRACE_SECONDS, 60) |
paybill | 30 minutes (CHARGE_PAYBILL_WINDOW_SECONDS, 1800) |
card | 30 minutes (CARD_UC_INTENT_TTL_SECONDS, 1800) |
Read expires_at from the charge rather than relying on these numbers.
What to show the payer
next_action is set while the charge is pending, and null once it ends. Branch on next_action.type.
type | Fields | Show |
|---|---|---|
await_payer | display, expires_at | display ("Enter your M-Pesa PIN on your phone" or "Approve the MTN MoMo prompt on your phone") and a countdown to expires_at |
pay_to_paybill | business_number, account_number, amount, expires_at | "Pay Bill business_number, account account_number, amount" and the time left. amount is in minor units: 250000 is KES 2,500.00 |
use_card_element | client_secret (create answer only), expires_at, amount, fee, total, currency | Mount the card element with client_secret. Show total as what the card is charged |
Learn the outcome
The webhook is the source of truth. Polling is for the screen the payer is looking at.
Webhooks
Subscribe your endpoint to these events. See Event catalogue for full payloads.
| Event | When | Charge fields in it |
|---|---|---|
payment.succeeded | The charge's payment was booked | charge, reference, metadata, failure (null), test |
payment.failed | The charge's payment failed (a mobile-money refusal, or a card charge that expired after the element opened a card attempt) | charge, reference, metadata, failure, test |
charge.expired | The charge reached expires_at while pending | charge, reference, metadata, status, test |
charge.cancelled | You cancelled the charge | charge, reference, metadata, status, test |
There is no charge.succeeded or charge.failed: success and failure arrive as payment.succeeded and payment.failed, carrying charge. charge.expired and charge.cancelled go only to whoever made the charge: you, or the platform that made it for you.
Polling
While the payer waits on your screen, read GET /charges/{id} every 2 seconds. Stop when status leaves pending, or at expires_at.
sh
curl https://payments-ke-staging.mookhpay.co/v1/payments/merchant/charges/ch_ke_8a3f0c2d9b1e4f5a6c7d8e9f \
-H "Authorization: Bearer $MOOKHPAY_SECRET_KEY"js
const API = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
const headers = { Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}` };
export async function waitForCharge(id, expiresAt) {
while (Date.now() < Date.parse(expiresAt)) {
const res = await fetch(`${API}/charges/${id}`, { headers });
const body = await res.json();
if (!body.ok) throw new Error(`${body.code}: ${body.description}`);
if (body.data.status !== "pending") return body.data;
await new Promise((resolve) => setTimeout(resolve, 2000));
}
return null;
}python
import os
import time
from datetime import datetime
import requests
API = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant"
HEADERS = {"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}"}
def wait_for_charge(charge_id, expires_at):
deadline = datetime.fromisoformat(expires_at.replace("Z", "+00:00")).timestamp()
while time.time() < deadline:
body = requests.get(f"{API}/charges/{charge_id}", headers=HEADERS, timeout=15).json()
if not body["ok"]:
raise RuntimeError(f"{body['code']}: {body['description']}")
if body["data"]["status"] != "pending":
return body["data"]
time.sleep(2)
return Nonephp
<?php
function waitForCharge(string $id, string $expiresAt): ?array
{
$api = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
$deadline = strtotime($expiresAt);
while (time() < $deadline) {
$ch = curl_init("$api/charges/$id");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("MOOKHPAY_SECRET_KEY")],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);
if (!$body["ok"]) {
throw new RuntimeException($body["code"] . ": " . $body["description"]);
}
if ($body["data"]["status"] !== "pending") {
return $body["data"];
}
sleep(2);
}
return null;
}Reads share 120 requests a minute with your checkout calls. One payer polled for one prompt fits in that; many payers at once do not, so rely on webhooks for those.
client_secret is never in a read. Only the create answer and its idempotent replay carry it.
Find a charge whose answer was lost
If the create call timed out, you do not know whether a prompt was sent. Either repeat the create with the same Idempotency-Key and body, which answers the same charge with 200 and sends no second prompt, or look the charge up by your reference with GET /charges?reference=. It lists the charges you made for that reference, newest first, whichever account they pay. limit is 1 to 100, 20 by default.
sh
curl "https://payments-ke-staging.mookhpay.co/v1/payments/merchant/charges?reference=order-8841&limit=5" \
-H "Authorization: Bearer $MOOKHPAY_SECRET_KEY"js
const API = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
const params = new URLSearchParams({ reference: "order-8841", limit: "5" });
const res = await fetch(`${API}/charges?${params}`, {
headers: { Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}` },
});
const body = await res.json();
if (!body.ok) throw new Error(`${body.code}: ${body.description}`);
for (const charge of body.data.charges) console.log(charge.id, charge.status);python
import os
import requests
API = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant"
body = requests.get(
f"{API}/charges",
params={"reference": "order-8841", "limit": 5},
headers={"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}"},
timeout=15,
).json()
if not body["ok"]:
raise RuntimeError(f"{body['code']}: {body['description']}")
for charge in body["data"]["charges"]:
print(charge["id"], charge["status"])php
<?php
$api = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
$query = http_build_query(["reference" => "order-8841", "limit" => 5]);
$ch = curl_init("$api/charges?$query");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("MOOKHPAY_SECRET_KEY")],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);
foreach ($body["data"]["charges"] as $charge) {
echo $charge["id"], " ", $charge["status"], "\n";
}The answer is { "charges": [ … ] }, each charge as GET /charges/{id} answers it. There is no cursor: this is a lookup by reference, not a list of every charge.
Retries and one charge per reference
- Send an
Idempotency-Keyon every create, 1 to 128 characters. The same key with the same body answers the same charge with200, and no second prompt is sent. - The same key with a different body answers
422and code3015. - One pending charge per
reference. A second create for a reference whose charge is stillpendinganswers409and code3002, withdata.chargenaming the pending charge. This stops a double click or a client retry sending two prompts for one order.
json
{
"ok": false,
"description": "A charge for this reference is still pending. Wait for it, or cancel it first",
"data": { "charge": "ch_ke_8a3f0c2d9b1e4f5a6c7d8e9f" },
"code": 3002
}- Once that charge has ended (
failed,expiredorcancelled), a new charge for the same reference is allowed. Use a newIdempotency-Keyfor it. - Idempotency keys and references are your own. A platform's never collide with the seller's.
Use the order id as reference, and the order id with the attempt number as the Idempotency-Key, such as order-8841-2.
Failure codes
failure is { code, message } on a failed charge and null otherwise. Branch on code. message is a plain sentence for your logs. The list is closed: a rail answer MOOKHPay does not map becomes declined.
code | Meaning | Produced by | Tell the payer |
|---|---|---|---|
payer_cancelled | The payer cancelled the prompt | M-Pesa, MoMo, test number 0700 000 003 | "You cancelled the payment. Try again when you're ready." |
insufficient_funds | Not enough money for this payment | M-Pesa, MoMo, card, test number 0700 000 001 | "There wasn't enough money for this payment. Top up and try again, or use another number." |
wrong_pin | The payer entered a wrong PIN | M-Pesa | "The PIN was wrong. Try again." |
prompt_timed_out | The prompt was not answered in time | M-Pesa, MoMo, test number 0700 000 002 | "The payment request timed out. Try again and approve it on your phone." |
phone_unreachable | The phone could not be reached | M-Pesa, MoMo | "We couldn't reach your phone. Check it is on and has signal, then try again." |
limit_exceeded | Over a limit on the payer's account | M-Pesa, MoMo, card | "This payment is over a limit on your account. Try a smaller amount or another number." |
rail_unavailable | The payment network could not take the payment | M-Pesa, MoMo, card | "The payment network is not responding. Try again in a few minutes." |
declined | Declined for any other reason, or a rail answer with no mapping | M-Pesa, MoMo, card | "The payment was declined. Try again, or use another method." |
Cancel a charge
POST /charges/{id}/cancel stops a pending charge being paid. It takes no body.
sh
curl -X POST https://payments-ke-staging.mookhpay.co/v1/payments/merchant/charges/ch_ke_8a3f0c2d9b1e4f5a6c7d8e9f/cancel \
-H "Authorization: Bearer $MOOKHPAY_SECRET_KEY"js
const API = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
const res = await fetch(`${API}/charges/ch_ke_8a3f0c2d9b1e4f5a6c7d8e9f/cancel`, {
method: "POST",
headers: { Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}` },
});
const body = await res.json();
if (!body.ok) throw new Error(`${body.code}: ${body.description}`);
console.log(body.data.status);python
import os
import requests
API = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant"
body = requests.post(
f"{API}/charges/ch_ke_8a3f0c2d9b1e4f5a6c7d8e9f/cancel",
headers={"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}"},
timeout=15,
).json()
if not body["ok"]:
raise RuntimeError(f"{body['code']}: {body['description']}")
print(body["data"]["status"])php
<?php
$api = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
$ch = curl_init("$api/charges/ch_ke_8a3f0c2d9b1e4f5a6c7d8e9f/cancel");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("MOOKHPAY_SECRET_KEY")],
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);
echo $body["data"]["status"] ?? $body["code"], "\n";- A
paybillcharge stops matching at once. A menu payment after that lands in yourmainwallet as an ordinary payment and does not pay the charge. - The hosted page at
hosted_urlstops taking new attempts. - A prompt already on the payer's phone cannot be recalled. If the payer approves it, the payment is booked and the charge becomes
succeeded. - Only a
pendingcharge can be cancelled. Any other status answers409and code3003. Cancelling a charge alreadycancelledanswers it again with200. - No body, or
{}. A non-empty body answers400and code1701. - Only the merchant or platform that made the charge can cancel it. A seller reading a charge a platform made for them gets
404and code3001on cancel. charge.cancelledis sent.
Test charges
A charge made with a staging key (mkp_test_) is a test charge, with "test": true. It is paid only by the four test numbers, in the deployment's own country code. No prompt is sent and nothing is booked, but the charge, the webhooks and the failure codes go through the same states as a real one.
| Key | A real number | A test number |
|---|---|---|
mkp_test_ (staging) | 409, code 2836 | Simulated. The number decides the outcome |
mkp_live_ (production) | A real prompt | 422, code 2838 |
| Number | Outcome | After |
|---|---|---|
0700 000 000 | succeeded | About 3 seconds |
0700 000 001 | failed, insufficient_funds | About 3 seconds |
0700 000 002 | failed, prompt_timed_out | About 60 seconds |
0700 000 003 | failed, payer_cancelled | About 3 seconds |
Send them as +254700000000 in Kenya or +256700000000 in Uganda. A test charge is mobile money only: paybill and card answer 400 and code 3004.
Limits
Prompts are limited so nobody can be pestered through MOOKHPay. Over any of the first three, the create answers 429 and code 3005, with Retry-After and data.retryAfter in seconds.
| Limit | Default | Counts |
|---|---|---|
| Prompts to one phone number, across every merchant | 5 an hour | mobile_money creates (CHARGE_PROMPTS_PER_PHONE). Test numbers are counted per merchant instead |
| Prompts to one phone number from your account | 3 an hour | mobile_money creates (CHARGE_PROMPTS_PER_PHONE_MERCHANT) |
| Charges created by your key's account | 300 an hour | Every create, any method (CHARGES_PER_KEY) |
| Reads, lists and cancels | 120 a minute, code 1804 | Shared with your checkout calls |
The amount is checked against the rail before the prompt. See Limits and rate limits.
Refusals when you create
| HTTP | Code | When |
|---|---|---|
400 | 1701 | A field breaks its rules, a field is unknown, Idempotency-Key is missing, metadata breaks its rules, the phone is not one the rail can prompt, or payer_email is malformed or sent with paybill |
400 | 3004 | paybill or card is not offered here, or the key is a staging key |
401 | 2781 | The key is missing, malformed, unknown or revoked |
403 | 2941 | The key does not have charges:write |
409 | 2709 | The payee's wallet is not set up yet. Try again in a moment |
409 | 2836 | A real number on a test charge |
409 | 3002 | A charge for this reference is still pending. data.charge names it |
422 | 2701 | rail is not the rail this deployment runs |
422 | 2702 | amount is outside the rail's limits |
422 | 2721 | Payments are switched off on this deployment |
422 | 2838 | A test number on a production key |
422 | 3015 | The Idempotency-Key was used with a different body |
429 | 3005 | A prompt or charge limit above |
503 | 2752, 2782 | The ledger or the key service did not answer. Retry with the same Idempotency-Key |
The full list, with the platform codes, is on Create a charge.
For platforms
A platform adds on_behalf_of and platform_fee to take a payment for a seller with its fee. The key also needs payments:write, the seller is the payee and the prompt names them, and the charge carries account, platform_fee and net. See Take payments with a fee.
Not offered
- Paying from a MOOKHPay balance. That needs the payer's own MOOKHPay session; send them to
hosted_url. - Saved cards, recurring charges, or charging a card you hold.
- Retrying a failed prompt on the same charge. Create a new charge.
- Refunds on this route. A paid charge is refunded with
POST /refundsand itscharge_id. See Refunds.