API documentation
Verify Telebirr, CBE and CBE Birr payments and take payments through hosted checkout pages.
Introduction
Hisab Pay lets your website, app or system accept Telebirr, CBE and CBE Birr payments and know they are real. Every payment is checked against the official receipt published by Ethio telecom or the Commercial Bank of Ethiopia — never against screenshots — and each transaction can pay only once.
Money always goes straight from the customer to your own accounts (or your sellers'); Hisab Pay never holds it.
Two ways to use it
- Checkout (easiest): create a payment with
POST /v1/paymentsand send the customer to itscheckout_url. Hisab Pay shows where to pay, checks the transaction, then sends the customer back to yoursuccess_urland your server apayment.paidwebhook. - Verify (your own payment page): the customer pays and types the transaction ID on your site; your server sends it to
POST /v1/verifyand gets the answer in seconds.
Base URL: https://pay.cassiacode.com. Requests and answers are JSON. Amounts are in birr as strings with two decimals ("1500.00") plus amount_santim as an integer (1 birr = 100 santim); you may send amounts as numbers (1500, 19.99) or strings ("1,500.50").
A machine-readable description is at /openapi.json (OpenAPI 3.1 — import it into Postman, Insomnia or a code generator).
Authentication
Create keys in the dashboard under API keys. Send the key in the Authorization header (or X-Api-Key). Keys are secret: use them only on your server, never in a browser or mobile app.
hp_test_…— test mode: accepts only test transaction IDs, never contacts a bank, works without accounts set up.hp_live_…— live mode: checks real payments.
Each key sees only its own mode: test payments and checks are invisible to live keys, and the other way round. Revoked keys stop working at once.
curl https://pay.cassiacode.com/v1/me -H "Authorization: Bearer hp_test_YOUR_KEY"Test mode
With a test key, use these transaction IDs. The word after TEST chooses the answer, so you can build every case without real money. Test checks and payments appear in the dashboard under Test.
| Word | Telebirr | CBE | CBE Birr | Answer |
|---|---|---|---|---|
OK | TESTOK1234 | FTTESTOK1234 | TESTOK12345 | verified (paid the expected amount, 100.00 if none sent) |
USED | TESTUSED12 | FTTESTUSED12 | TESTUSED123 | already_used |
LOW | TESTLOW123 | FTTESTLOW123 | TESTLOW1234 | amount_mismatch (pays half) |
OTHER | TESTOTHER1 | FTTESTOTHER1 | TESTOTHER12 | wrong_receiver |
NONE | TESTNONE12 | FTTESTNONE12 | TESTNONE123 | not_found |
PEND | TESTPEND12 | FTTESTPEND12 | TESTPEND123 | not_completed |
DOWN | TESTDOWN12 | FTTESTDOWN12 | TESTDOWN123 | 503 bank_unavailable |
The test receipt pays the amount you sent. A live key refuses test IDs (test_reference) and a test key refuses real ones (live_reference).
Errors
Check outcomes (verified, not found, already used…) are normal answers with HTTP 200 — see the check object. Problems with the request itself use HTTP error codes and this body:
{
"error": {
"code": "invalid_request",
"message": "amount must be at least 1 birr",
"field": "amount"
}
}| HTTP | code | When |
|---|---|---|
| 400 | invalid_request | The body isn't JSON or a field is wrong; field names it. |
| 400 | invalid_reference | reference isn't a Telebirr, CBE or CBE Birr transaction ID. |
| 400 | test_reference | A test transaction ID was sent with a live key. |
| 400 | live_reference | A real transaction ID was sent with a test key. |
| 401 | invalid_key | The key is missing, malformed, unknown or revoked. |
| 402 | plan_limit | Your Hisab Pay plan's checks are used up (the free trial has 200). Upgrade in the dashboard → Plan & billing; billing_url given. Test mode is always free. |
| 402 | plan_expired | Your paid plan's month has ended. Renew it in the dashboard → Plan & billing; billing_url given. |
| 403 | merchant_paused | The merchant (recipient) is switched off for taking payments in the dashboard → Merchants. |
| 403 | payouts_paused | Payouts to this merchant (recipient) are switched off in the dashboard → Merchants. |
| 403 | merchant_key | A merchant API key can't do this (it may check payments and make / read its merchant's payments only). |
| 403 | recipient_mismatch | A merchant API key named another merchant in recipient; leave it out or use the key's own merchant. |
| 403 | platform_only | accounts was sent by a business that isn't a platform; add your accounts in the dashboard instead. |
| 404 | recipient_not_found | No active recipient has that recipient ID. |
| 404 | not_found | No payment or check with that ID for this key's business and mode. |
| 409 | no_accounts | Your business (or the recipient) has no account for that service yet. |
| 409 | not_pending | The payment or payout isn't pending any more (paid, expired or canceled). |
| 409 | not_refundable | Only paid payments can be refunded. |
| 409 | refund_too_large | The refund is more than is left to refund (refunds waiting to be sent count too). |
| 429 | rate_limited | Too many checks in 24 hours; retry: true. |
| 500 | internal_error | Something failed on our side; retry: true. |
| 503 | bank_unavailable | The bank's receipt service didn't answer; retry: true, check_id given. |
| 503 | unavailable | Hisab Pay itself is briefly unavailable; retry: true. |
When retry: true is present, try again later (e.g. after a minute). Never treat an error as "paid".
Check a transaction
POST /v1/verify — checks one transaction against the official receipt. The customer pays one of your accounts and gives you the transaction ID (or pastes the whole SMS — the ID is found in it).
| Field | Type | |
|---|---|---|
reference | string, required | The transaction ID: Telebirr 10 letters/digits (DJ10AO86X4), CBE FT + 10 (FT26274T6519), CBE Birr 11 (DIU21Q510UY). A pasted SMS or receipt link works too. CBE transfer SMS have no FT number: the customer's SMS or its mbreciept.cbe.com.et/v2-… link is matched with the CBE SMS your SMS phone forwarded (answers not_found until that SMS arrives; confirmed_by: "sms"). |
method | string | telebirr, cbe or cbe_birr. Guessed from the ID's shape when left out. |
amount | number or string | Expected amount in birr. The payment must be at least this much (more is fine). |
order_id | string ≤ 100 | Your order. The transaction is claimed for it; asking again for the same order is safe (idempotent). |
recipient | string | Your ID for a recipient (seller, branch, driver): the money must have reached *their* accounts instead of yours. |
claim | boolean | Default true. false = only look; the transaction stays free for another order. |
Note: A check can take 1–30 seconds (the bank's receipt service is slow at times). Use a 60-second timeout on your side.
curl -X POST https://pay.cassiacode.com/v1/verify \
-H "Authorization: Bearer hp_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"reference": "TESTOK1234", "amount": 1500, "order_id": "1001"}'The check object
id, object: "check", status, verified (true only for verified), livemode, method, reference; when a receipt was found: amount, amount_santim, currency, paid_on, payer, receiver, receiver_account, confirmed_by (receipt, sms or test — see SMS phones); bank_status (not completed); expected_amount; recipient {id, name}; order_id; claimed + claimed_at; used_by {order_id, at} (already used).
Fraud guard (live checks): when something looks wrong the check also has risk {flagged: true, reasons: […], hold}. Reasons: blocked_payer (the payer's name is on your blocklist — hold is true: don't deliver before you've looked; Hisab Pay's own checkout pages hold such payments), large_amount (at or above your limit, or about 10× your usual), burst (many payments from one payer within 30 minutes), reused_id / wrong_ids (checkout pages and Telegram only). Every flag is also a risk.flagged webhook event and appears in the dashboard → Fraud guard.
| status | Meaning |
|---|---|
verified | Completed, paid into your (or the recipient's) account, at least the expected amount. Claimed for your order unless claim: false. |
already_used | This transaction was already used for another order or payment; used_by says which. |
amount_mismatch | Paid to you, but less than amount. The real amount is in amount. |
wrong_receiver | The money went to an account that isn't yours (or the recipient's). |
not_found | The bank has no such transaction (for your accounts). It may be a typo, or too new: try again in a minute. |
not_completed | The transaction exists but isn't completed; bank_status has the bank's word. |
GET /v1/checks/{id} returns a check again (for example after a 503 bank_unavailable, which includes check_id).
Payments and checkout
POST /v1/payments — asks for a payment and returns a checkout_url. Send the customer there (redirect, link, QR code, SMS). The page shows the amount and your accounts, takes the transaction ID, checks it, and sends the customer to success_url with ?payment_id=…&status=paid added.
Note: Don't trust the redirect alone — anyone can open your success URL. Confirm with the payment.paid webhook or GET /v1/payments/{id} before delivering the goods.
| Field | Type | |
|---|---|---|
amount | number or string, required | Birr, at least 1. |
description | string ≤ 200 | Shown to the customer. |
order_id | string ≤ 100 | Your order; shown to the customer and searchable. |
recipient | string | Your recipient's ID: the customer pays into their accounts. |
methods | array | Any of telebirr, cbe, cbe_birr (default: all you have accounts for). |
customer | object | name, phone, email (optional, for your records). |
metadata | object | Up to 20 keys of strings/numbers/booleans; returned as given. |
success_url, cancel_url | https URL | Where to send the customer after paying, or when they go back. |
expires_in | integer | Minutes until it expires: 5 to 43200 (30 days). Default: your business's setting (1 day unless changed in Settings). |
curl -X POST https://pay.cassiacode.com/v1/payments \
-H "Authorization: Bearer hp_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"amount": 1500, "description": "Order #1001", "order_id": "1001",
"success_url": "https://shop.et/thanks", "cancel_url": "https://shop.et/cart"}'Other payment calls
GET /v1/payments/{id}— one payment.GET /v1/payments— newest first. Query:status,order_id,limit(1–100, default 20),before(acreated_atfrom the previous page). Answers{ object: "list", data: [...], has_more }. Withpaid_since(a date-time) it lists paid payments from then on, oldest paid first — handy for copying payments into your books; ask again with the lastpaid_atwhilehas_more.POST /v1/payments/{id}/cancel— cancels a pending payment (its checkout page stops accepting payments);409 not_pendingotherwise.
| status | Meaning |
|---|---|
pending | Waiting for the customer to pay on the checkout page. |
paid | Paid and verified; paid_with says how. |
expired | Not paid before expires_at. |
canceled | Canceled by you (API or dashboard). |
When paid, paid_with holds method, reference, amount, amount_santim, payer and check_id. Payments made through a payment link have link_id. refunded / refunded_santim is the total of confirmed refunds.
No-typing checkout. When one of your SMS phones watches the account a customer pays into, the checkout page asks for a slightly unique amount — the price plus 0.01–0.99 ETB, e.g. 100.03 for a 100.00 payment — and the payment confirms itself as soon as the phone sees exactly that amount arrive; the customer types nothing (typing the transaction ID still works). The payment object then has exact_amount / exact_amount_santim, and paid_with.amount is what was received. Owners can switch it off in Settings.
Refunds
POST /v1/payments/{id}/refunds creates a refund — a payout (kind: "refund", payment_id) back to the customer. All fields are optional: amount (default: everything not refunded yet), method (default: how they paid), account (default: the customer's phone when it fits), name, description, external_id. Then send the money and confirm it with POST /v1/payouts/{id}/confirm, like any payout. Refunds waiting to be sent count against the limit, so a payment can never be refunded twice; when one is confirmed, the payment's refunded grows and a payment.refunded webhook is sent.
curl -X POST https://pay.cassiacode.com/v1/payments/PAYMENT_ID/refunds \
-H "Authorization: Bearer hp_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"amount": 500, "description": "Returned 1 shirt"}'Webhooks
Add an endpoint in the dashboard under Webhooks (an https URL on your server, the events you want, live or test). Hisab Pay then POSTs a signed JSON event each time something happens.
| Event | When |
|---|---|
payment.paid | A payment was paid on its checkout page. |
payment.expired | A pending payment passed expires_at. |
payment.canceled | A payment was canceled. |
payment.created | A payment was created (API, dashboard or payment link). |
payment.refunded | A refund of the payment was confirmed; refunded shows the total refunded so far. |
check.completed | A POST /v1/verify check finished (any outcome). |
check.flagged | A payment confirmed by SMS didn't match the official receipt when it was checked later (flagged.reason). Look into it before delivering more. |
risk.flagged | Fraud guard raised a flag: data.object is the flag (kind: reused_id, wrong_ids, large_amount, burst, blocked_payer, edited_proof; check_id, payment_id, reference, amount, payer, held, detail). |
payout.created | A payout was created. |
payout.paid | A payout was confirmed: the receipt shows the payee got the money. |
payout.canceled | A payout was canceled. |
{
"id": "0b8a4e3f-5c1d-4f7e-8a2b-9c6d1e0f3a7b",
"object": "event",
"type": "payment.paid",
"livemode": true,
"created_at": "2026-10-02T09:05:41.000Z",
"data": {
"object": {
"id": "7dc9b6f8-1959-4c41-94fd-d51b94d3c54b",
"object": "payment",
"status": "paid",
"amount": "1500.00",
"order_id": "1001",
"paid_with": {
"method": "telebirr",
"reference": "DJ10AO86X4",
"amount": "1500.00",
"amount_santim": 150000,
"payer": "Abebe Kebede",
"check_id": "6f1c2b9e-1d0a-4c55-9a43-2c1f7f0d8e21"
}
// … the rest of the payment object
}
}
}- Headers:
Hisab-Pay-Event(the type),Hisab-Pay-Delivery(a delivery ID),Hisab-Pay-Signature. - Answer with any 2xx within 10 seconds (do slow work afterwards). Redirects aren't followed.
- Otherwise it's retried after 1 min, 5 min, 30 min, 2 h, 6 h and 12 h, then marked failed. You can resend any delivery from the dashboard.
- The same event can arrive more than once (retries, resends): use the event
idto ignore repeats. - Payment events carry the payment as it is when sent, so a late retry shows the latest status.
Checking the signature
Hisab-Pay-Signature: t=<unix seconds>,v1=<hex> where v1 = HMAC-SHA256 of "<t>.<raw body>" with your endpoint's secret (whsec_…, shown once when you add the endpoint). Compute it over the raw body before parsing JSON, compare in constant time, and refuse timestamps older than 5 minutes.
import { createHmac, timingSafeEqual } from "node:crypto";
// rawBody: the request body exactly as received (a string), e.g. await request.text()
export function isFromHisabPay(rawBody, header, secret) {
const t = Number(/(?:^|,)t=(\d+)/.exec(header ?? "")?.[1]);
const v1 = /(?:^|,)v1=([0-9a-f]{64})/.exec(header ?? "")?.[1];
if (!t || !v1 || Math.abs(Date.now() / 1000 - t) > 300) return false;
const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest();
return timingSafeEqual(expected, Buffer.from(v1, "hex"));
}
// Next.js route handler
export async function POST(request) {
const raw = await request.text();
if (!isFromHisabPay(raw, request.headers.get("hisab-pay-signature"), process.env.HISAB_PAY_WEBHOOK_SECRET)) {
return new Response("bad signature", { status: 400 });
}
const event = JSON.parse(raw);
if (event.type === "payment.paid") {
// mark the order with event.data.object.order_id paid (once per event.id)
}
return new Response("ok");
}Payouts (money out)
A payout is money you send — to a seller, driver, supplier or a customer. You send it yourself with your Telebirr, CBE or CBE Birr app or bank (Hisab Pay never holds money), then give Hisab Pay the transaction ID: the official receipt is read and the payout becomes paid only if the payee's account received at least the amount. Each transaction can confirm one payout (or payment) only.
POST /v1/payouts— create a payout.POST /v1/payouts/{id}/confirmwith{"reference": "…"}— after you sent the money.GET /v1/payouts/{id},GET /v1/payouts(querystatus,external_id,limit,before),POST /v1/payouts/{id}/cancel.
| Field | Type | |
|---|---|---|
amount | number or string, required | Birr, at least 1. |
method | string, required | telebirr, cbe or cbe_birr. |
account | string | The payee's phone (09…/07…) or 13-digit CBE account. Optional with recipient. |
name | string | The payee's name. Optional with recipient. |
recipient | string | Your recipient's ID: their account for method and their name are used. |
description | string ≤ 200 | What it's for. |
external_id | string ≤ 100 | Your own ID. Creating again with the same external_id returns the first payout (safe retries). |
metadata | object | Up to 20 keys; returned as given. |
curl -X POST https://pay.cassiacode.com/v1/payouts \
-H "Authorization: Bearer hp_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"amount": 250, "method": "telebirr", "account": "0911223344", "name": "Abebe Kebede",
"description": "Week 40 earnings", "external_id": "w40-abebe"}'
# after sending the money:
curl -X POST https://pay.cassiacode.com/v1/payouts/PAYOUT_ID/confirm \
-H "Authorization: Bearer hp_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"reference": "TESTOK1234"}'Confirming answers 200 with the payout and last_check (the check object) whenever the receipt was read: if last_check.status isn't verified (for example wrong_receiver or amount_mismatch), the payout stays pending and you can confirm again with the right transaction. Test keys confirm with test IDs (TESTOK1234…).
merchant_fee / merchant_fee_santim: what you charge the merchant for this payout, from the payout fee set on the merchant in the dashboard (Merchants → Switches and fees). Hisab Pay never deducts it — the payout amount is what the merchant receives; the fee is for your own settlement with the merchant. It is filled in when a live payout to a recipient is confirmed paid, worked out on the amount the receipt shows, and stays null for test payouts, payouts to someone else, refunds, and payouts not yet paid.
| status | Meaning |
|---|---|
pending | To send: you haven't confirmed a transfer yet. |
paid | Confirmed by the receipt; paid_with says how. |
canceled | Canceled before it was sent. |
Many payouts at once
POST /v1/payout_batches with {"name": "Week 40", "payouts": [ … ]} — 1 to 500 payouts, each with the same fields as above. Every line is checked first: if any is wrong, nothing is saved and the answer lists them all in error.errors (index, field, message). Each line becomes a normal payout (confirm each with its own transfer). GET /v1/payout_batches/{id} returns the batch's totals (count, paid, pending) and all its payouts. In the dashboard you can paste a list from Excel or upload a CSV instead.
curl -X POST https://pay.cassiacode.com/v1/payout_batches \
-H "Authorization: Bearer hp_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Week 40", "payouts": [
{"amount": 250, "method": "telebirr", "account": "0911223344", "name": "Abebe", "external_id": "w40-1"},
{"amount": 400, "method": "cbe", "account": "1000123454321", "name": "Almaz", "external_id": "w40-2"},
{"amount": 120, "method": "telebirr", "recipient": "driver-7", "external_id": "w40-3"}
]}'Recipients (marketplaces)
If customers pay your sellers, drivers or branches directly, add each one in the dashboard under Recipients with your own ID for them (e.g. seller-17) and their accounts. Then send "recipient": "seller-17" with POST /v1/verify or POST /v1/payments: the money must reach *that recipient's* accounts. One account number can belong to only one place in your business, so a payment's receiver is never ambiguous.
Merchant keys
A key can belong to one merchant (dashboard → Merchants → the merchant → API keys; merchants can also make their own in their portal). Such a key works only for that merchant: POST /v1/verify and POST /v1/payments use its accounts without a recipient field, GET /v1/payments and GET /v1/checks/{id} show only its payments, and GET /v1/me names it in merchant. Payouts, payout batches and refunds answer 403 merchant_key.
Payment links (no code)
In the dashboard under Payment links you can make a reusable link (/p/…) with a fixed amount or one the customer types, optionally asking for their name and phone. Share it on Telegram, WhatsApp or a poster. Each customer gets a normal payment (with link_id) — the same webhooks fire. Links are managed in the dashboard only for now.
SMS phones (faster, works when a bank is down)
Banks' receipt pages are sometimes slow or down. Put the SIM that receives your payment SMS in an Android phone, install the Hisab Pay SMS app and pair it in the dashboard under SMS phones. The app forwards only money SMS from the banks' and Telebirr's own sender names (never personal messages). A check then uses the SMS when it's there: same transaction ID, sent to one of that phone's accounts, at least the amount.
- Answers confirmed this way have
confirmed_by: "sms". Nothing else changes for your code. - Each one is checked against the official receipt a few minutes later. If the receipt disagrees (another receiver, a smaller amount, no such transaction), you get a
check.flaggedwebhook and a warning in the dashboard. - A checkout payment the customer submitted while the bank was down is completed automatically when the SMS arrives.
- The app: hisab-pay-sms.apk (Android 7+, installed from the file).
Libraries and plugins
Ready-made code so you write a few lines instead of building requests by hand. All of them check webhook signatures for you.
- Node.js (18+, no dependencies): hisab-pay-node.zip — unzip into your project and
import { HisabPay, verifyWebhook } from "./hisab-pay/index.js". Types included. - PHP (7.4+, curl, no dependencies): hisab-pay-php.zip —
require 'hisab-pay-php/src/HisabPay.php';thennew \HisabPay\Client($key). - WooCommerce: hisab-pay-woocommerce.zip — Plugins → Add New → Upload. Customers pay on the Hisab Pay checkout page (English or Amharic); orders are marked paid on return, by webhook (
/wp-json/hisab-pay/v1/webhook) or by re-checks. Store currency must be ETB.
import { HisabPay, verifyWebhook } from "./hisab-pay/index.js";
const hp = new HisabPay({ apiKey: process.env.HISAB_PAY_KEY });
const payment = await hp.payments.create({ amount: 1500, order_id: "1001", success_url: "https://shop.et/thanks" });
// redirect to payment.checkout_url
const check = await hp.verify({ reference: "TESTOK1234", amount: 1500, order_id: "1002" });
const payout = await hp.payouts.create({ amount: 250, method: "telebirr", account: "0911223344", name: "Abebe" });
await hp.payouts.confirm(payout.id, "TESTOK5678");Limits and good practice
- Up to 2,000 checks per business per 24 hours (live and test together); then
429 rate_limited. - The checkout page allows 10 tries per payment per 10 minutes.
- A transaction ID can pay one order or payment only (per business and mode). Asking again for the same
order_idis safe. - Keep keys and webhook secrets on your server. Revoke a key in the dashboard if it leaks; make a new webhook secret the same way.
- Never mark an order paid on an error or timeout — only on
verified: trueor apayment.paidevent.