Skip to content

Retrieve fees ​

Reads what MOOKHPay charges on this host for money in and out: the payout fee for each rail, the mobile-money top-up fee, and the card fee. It is the same quote the MOOKHPay app shows people.

Use it before a payout, to show the fee before the person confirms, and to offer "withdraw everything": a pocket can pay out at most its balance less payout.<rail>.total. The fee on the payout itself is final; this is a quote.

Endpoint ​

GET /v1/payments/merchant/fees
AuthSecret key, Authorization: Bearer mkp_…
ScopeAny one of accounts:read, payouts:write or transfers:write
PlatformThe key's organisation must be an active platform, and the call must come from an address on its allow-list if it has one
Switched onRegistered only where the platform API is on

Headers ​

HeaderRequiredValue
AuthorizationYesBearer mkp_test_… or Bearer mkp_live_…

There are no parameters.

Example request ​

sh
curl https://payments-ke-staging.mookhpay.co/v1/payments/merchant/fees \
  -H "Authorization: Bearer $MOOKHPAY_SECRET_KEY"
js
const BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
const account = "acct_ke_9c2f41b07e5d38a6c1f0b294";
const headers = { Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}` };

const [fees, balance] = await Promise.all(
  [`${BASE}/fees`, `${BASE}/accounts/${account}/balance`].map(async (url) => {
    const res = await fetch(url, { headers });
    const answer = await res.json();
    if (!answer.ok) throw new Error(`${res.status} ${answer.code}: ${answer.description}`);
    return answer.data;
  }),
);

// The most this pocket can pay out to M-Pesa, in whole currency units.
const fee = Number(fees.payout.mpesa.total);
const most = Math.floor(Math.max(0, balance.available - fee) / 100) * 100;
console.log(`Withdraw up to ${fees.currency} ${(most / 100).toFixed(2)}, fee ${fee / 100}`);

Response ​

200 OK with description Fees.

json
{
  "ok": true,
  "description": "Fees",
  "data": {
    "currency": "KES",
    "payout": {
      "mpesa": { "rail_fee": "0", "mookhpay_fee": "0", "total": "0" }
    },
    "topup": {
      "mpesa": { "rail_fee": "0", "mookhpay_fee": "0", "total": "0" }
    },
    "card": { "KES": "0" }
  }
}

Response fields ​

Every amount is a string of minor units. Every fee is "0" where none is set.

FieldTypeMeaning
currencystringThe host's wallet currency: KES in Kenya
payoutobjectOne entry per payout rail this host runs, keyed by rail (mpesa in Kenya)
payout.<rail>.rail_feestringWhat the rail charges for a payout
payout.<rail>.mookhpay_feestringWhat MOOKHPay adds
payout.<rail>.totalstringrail_fee plus mookhpay_fee. What a payout to a phone on this rail costs on top of amount, from the same wallet or pocket
topupobjectOne entry per mobile-money rail this host collects on, with the same three fields. What a person adds when they top up their own wallet by mobile money in MOOKHPay. mookhpay_fee is always "0"
cardobjectThe card fee per currency, keyed by currency code, added on top when someone pays by card. Empty where card payments are off

A pay-in (Create a transfer) has no fee and is not listed.

Errors ​

HTTPCodeNameWhenWhat to do
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 has none of accounts:read, payouts:write and transfers:writeUse your platform key
4033042API_KEY_IP_NOT_ALLOWEDThe account has allowed addresses and the call came from another addressCall from a listed address
4032942PLATFORM_NOT_ENABLEDThe organisation is not an active platformAsk MOOKHPay
4033013PLATFORM_IP_NOT_ALLOWEDThe call came from an address not on your allow-listCall from a listed address
4291804RATE_LIMIT_EXCEEDEDOver the rate limit belowWait Retry-After seconds
5032782AUTHN_UNAVAILABLEKeys cannot be checkedRetry with backoff

Rate limit ​

120 requests a minute per platform, or the higher number MOOKHPay set for it. Over it: 429, code 1804, with Retry-After and data.retryAfter in seconds. The fees change rarely: read them once a few minutes and cache them.

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