Accept payments from your customers through Ibtiaath
Your server asks us for a payment. You open the checkout link we return in a WebView or browser. Your customer pays by bank card, ZainCash or installments. You learn the result from a signed webhook and can ask for it at any time. We collect, and pay out to you in a periodic settlement.
Overview
Ibtiaath Pay is a hosted checkout. You never handle card numbers, wallet PINs or OTP codes: the customer enters those on Ibtiaath's page or the payment provider's page. Your systems only ever see the payment's status, method and amounts.
- Your amount is final. The amount you send is what you are owed. Your own discounts are applied by you before you send it; you may send us a record of them, which we keep but never deduct.
- Fees are added on top. The customer pays your amount plus our service fee plus the fee of the method they choose. See Fees.
- Every payment is a permanent record. Each attempt, each result and each notification is a row in the payment's ledger, which can only be added to. See The payment ledger.
From onboarding to settlement من التسجيل حتى التسوية
- Agreement. Commercial terms are agreed: our service fee, which payment methods you offer, payment limits, and the settlement schedule.
- You send us your details. Company, contacts, URLs and bank account. The full list is in What you send us.
- We set you up on staging. You receive a test key, a webhook secret and the staging URLs. Test payments move no money.
- You integrate and test. Create payments, open the checkout, handle the webhook, cover every status. Run the go-live checklist.
- Review. We look at a few of your test payments and webhook answers together with you.
- Production. You receive your live key and webhook secret over a secure channel. A first small real payment is made on each method and checked on both sides.
- Live. Your customers pay. You fulfil orders from the webhook or the status call.
- Settlement · التسوية. For each period we send a statement and transfer what you are owed to your bank account. See Settlement.
Onboarding
Onboarding is done with your Ibtiaath account manager. Nothing in this section is self-service: keys and settings are created by Ibtiaath staff and every change to them is recorded.
Timeline
- Staging access: as soon as we receive the technical details in What you send us.
- Production access: after the go-live checklist is complete, the review is done, and the commercial and banking details are confirmed.
What you send us المطلوب منكم
Company
| Item | Why we need it | |
|---|---|---|
| Legal company name and registration number | The agreement and the settlement statements are issued to it. | Required |
| Display name | Shown to your customers at the top of the checkout, e.g. "EMAC". | Required |
| What you sell and typical amounts | Sets your minimum and maximum payment, and which methods fit (installments start at 10,000 IQD). | Required |
| Expected monthly volume | Capacity and limits. | Recommended |
People
| Contact | For | |
|---|---|---|
| Business contact | Terms, fees, disputes. | Required |
| Technical contact | Integration, key delivery, incidents. Receives the keys. | Required |
| Finance contact | Settlement statements and transfers. | Required |
Technical
| Item | Details | |
|---|---|---|
| Webhook URL (staging and production) | HTTPS, on a public address, answering within 10 seconds. One URL per environment. | Required |
| Return URL prefixes | Where the checkout sends the customer when done. Every return_url you send must start with one of these, e.g. https://app.example.com/pay/ or your app scheme yourapp://pay/. | Required |
| Server IP addresses | Only these addresses may use your key. Leave empty to allow any address (the signature still protects every call). | Optional |
| Payment limits | Smallest and largest single payment you want to accept. | Optional |
| Checkout link lifetime | How long a link stays payable. Default 30 minutes. | Optional |
| Checkout language | Arabic (default) or English; can also be chosen per payment. | Optional |
Settlement
| Item | Details | |
|---|---|---|
| Bank name and branch | Where settlements are paid. | Required |
| Account holder name | Must match the legal company name. | Required |
| Account number / IBAN | Sent in writing from your finance contact; confirmed by a call before the first transfer. | Required |
| Statement email | Where each period's statement is sent. | Required |
Changing bank details always requires a written request from your registered finance contact, followed by a confirmation call. We never change them on the strength of an email alone.
What we send you
| Item | Used for | Keep where |
|---|---|---|
Key ID, e.g. ibk_test_… / ibk_live_… | Identifies your key on every request (X-Ibt-Key). | Server config |
| API secret | Signs your requests. Shown once; we cannot show it again, only issue a new one. | Server secret store only |
| Webhook secret | Verifies the webhooks we send you. | Server secret store only |
| API base URL and checkout host | See Environments. | Server config |
Never put a secret in a mobile app or a web page. Anyone can extract it from there. Your app talks to your server; only your server talks to our API.
Keys can be rotated without downtime: we issue a second key, you switch to it, then we revoke the first.
Environments
| Staging (testing) | Production | |
|---|---|---|
| API base | https://api.staging.ibtiaath.com/api/v1/merchant | https://api.ibtiaath.com/api/v1/merchant |
| Checkout host | https://pay.staging.ibtiaath.com | https://pay.ibtiaath.com |
| Key prefix | ibk_test_ | ibk_live_ |
| Money | None: test payments are completed with a simulate button | Real |
Keys and secrets are different per environment. A staging key does not work in production, and the reverse.
How a payment runs
Signing requests
Every request carries three headers. There is no password or bearer token on the wire.
X-Ibt-Key: <key id>
X-Ibt-Timestamp: <unix time in seconds>
X-Ibt-Signature: <hex HMAC-SHA256 of string_to_sign, keyed with your API secret>
string_to_sign = timestamp + "." + METHOD + "." + path_with_query + "." + sha256_hex(raw_body)
METHODin upper case.path_with_queryexactly as sent, starting at/api/v1/merchant/…, including the query string.raw_bodyis the exact bytes you send. With no body, it is the empty string (SHA-256e3b0c442…b855).- The timestamp must be within 5 minutes of real time. Keep your server clock synced (NTP).
- Each signature is accepted once. To retry a request, sign it again.
Node.js
const crypto = require('crypto');
function ibtHeaders(keyId, secret, method, pathWithQuery, body = '') {
const ts = Math.floor(Date.now() / 1000).toString();
const bodyHash = crypto.createHash('sha256').update(body).digest('hex');
const sig = crypto.createHmac('sha256', secret)
.update(`${ts}.${method}.${pathWithQuery}.${bodyHash}`).digest('hex');
return { 'X-Ibt-Key': keyId, 'X-Ibt-Timestamp': ts, 'X-Ibt-Signature': sig,
'Content-Type': 'application/json' };
}
const path = '/api/v1/merchant/payments';
const body = JSON.stringify(payment); // send exactly these bytes
const res = await fetch(BASE_HOST + path, { method: 'POST', body,
headers: ibtHeaders(KEY_ID, API_SECRET, 'POST', path, body) });
PHP
function ibt_headers(string $keyId, string $secret, string $method, string $path, string $body = ''): array {
$ts = (string) time();
$sig = hash_hmac('sha256', $ts . '.' . $method . '.' . $path . '.' . hash('sha256', $body), $secret);
return ["X-Ibt-Key: $keyId", "X-Ibt-Timestamp: $ts", "X-Ibt-Signature: $sig",
'Content-Type: application/json'];
}
Python
import hashlib, hmac, time
def ibt_headers(key_id, secret, method, path, body=b''):
ts = str(int(time.time()))
to_sign = f'{ts}.{method}.{path}.{hashlib.sha256(body).hexdigest()}'
sig = hmac.new(secret.encode(), to_sign.encode(), hashlib.sha256).hexdigest()
return {'X-Ibt-Key': key_id, 'X-Ibt-Timestamp': ts, 'X-Ibt-Signature': sig,
'Content-Type': 'application/json'}
Create a payment
POST /payments
{
"order_id": "EMAC-2026-000123",
"amount": 250000,
"currency": "IQD",
"customer": { "id": "stu_8841", "name": "Ali Hassan",
"email": "ali@example.com", "phone": "+9647701234567" },
"product": { "id": "ielts-b2", "name": "IELTS Preparation B2" },
"promo": { "used": true, "code": "WELCOME10", "discount_amount": 25000 },
"return_url": "https://app.example.com/pay/done",
"locale": "ar",
"metadata": { "branch": "Baghdad" }
}
| Field | Rules | |
|---|---|---|
order_id | Required | Your own id for the order, up to 100 characters (letters, digits, . _ - : /). It is the idempotency key. |
amount | Required | The final amount you want to receive. Whole IQD, within your limits. |
currency | IQD only. | |
customer.name | Required | Shown on the checkout. |
customer.email / customer.phone | One required | Phone as digits with optional leading +. |
customer.id | Recommended | Your id for the customer. Lets us keep one record per customer. |
product.name | Required | Shown on the checkout. product.id is optional. |
promo | A record of your own discount. Never deducted. | |
return_url | Must start with one of your registered prefixes. | |
locale | ar (default) or en. | |
metadata | Your own JSON, up to 2,000 characters, returned unchanged. |
Answer 201 Created: the payment object, plus checkout_url and methods, what each method would cost right now:
{
"id": "PAY-9F3A61C2B7D4", "status": "pending",
"amount": 250000, "service_fee": 5000, "subtotal": 255000,
"checkout_url": "https://pay.ibtiaath.com/c/PAY-9F3A61C2B7D4#k7…",
"expires_at": "2026-12-02T11:05:00Z",
"methods": [
{ "code": "card", "fee": 0, "total": 255000 },
{ "code": "zaincash", "fee": 1530, "total": 256530 },
{ "code": "installments", "fee": 12750, "total": 267750, "months": 10, "monthly": 30792 }
],
…
}
Idempotency
- The same
order_idagain, while its payment is pending or paid, returns that same payment (200) with the samecheckout_urlwhile it can still be used. Safe to retry after a timeout. - The same
order_idwith a differentamountis refused:409 order_id_conflict. - After a payment expires or is cancelled, the same
order_idcreates a new payment.
Open the checkout
Open checkout_url exactly as received. The part after # is a one-payment secret: it never reaches any server log, and the page removes it from the address bar as soon as it loads.
WebView requirements
- JavaScript and cookies on.
- Allow navigation to other hosts: the bank's 3-D Secure page and ZainCash's page open from the checkout and return to it.
- Watch for navigation to your
return_url, then close the WebView. It arrives asreturn_url?payment_id=PAY-…&order_id=…&status=paid|pending|expired|cancelled - That
statusis for your screen only. Before you deliver anything, confirm with the webhook orGET /payments/{id}. - The link stays payable until the payment is paid, cancelled or expired (30 minutes by default).
The checkout follows Ibtiaath's app design, in Arabic (right to left) or English. It shows your display name, the product, your amount, one fee line, and the total for the chosen method.
Payment methods
Which methods appear is set per merchant by Ibtiaath and returned in methods. A method outside its own limits for that amount is left out. Only one payment can be in progress at a time: once a method has taken the money, the others are refused.
Read a payment
GET /payments/{id} is the source of truth.
{
"id": "PAY-9F3A61C2B7D4", "order_id": "EMAC-2026-000123", "status": "paid", "test": false,
"currency": "IQD", "amount": 250000, "service_fee": 5000, "subtotal": 255000,
"gateway_fee": 1530, "total_paid": 256530, "method": "zaincash",
"transaction_id": "TXN-4C1D09AB77E2",
"created_at": "2026-12-02T10:35:00Z", "expires_at": "2026-12-02T11:05:00Z", "paid_at": "2026-12-02T10:41:07Z",
"customer": { … }, "product": { … }, "promo": { … }, "metadata": { … },
"attempts": [
{ "no": 1, "method": "card", "fee": 0, "total": 255000, "status": "failed", "reason": "declined",
"started_at": "2026-12-02T10:36:12Z", "ended_at": "2026-12-02T10:37:40Z" },
{ "no": 2, "method": "zaincash", "fee": 1530, "total": 256530, "status": "succeeded",
"transaction_id": "TXN-4C1D09AB77E2", "started_at": "…", "ended_at": "…" }
]
}
Other calls
| Call | What it does |
|---|---|
GET /payments?order_id=… | Find a payment by your id. Also status, from, to (dates), limit (max 100), offset. Returns {"data": [...], "has_more": false}. |
GET /payments/{id}/events | The payment's full ledger. |
POST /payments/{id}/cancel | Cancel an unpaid payment. Refused with 409 payment_in_progress while the customer is paying. |
The payment ledger
Every payment keeps a ledger: one row for each thing that happened to it. Rows are only ever added. None is changed or deleted, and each row carries the hash of the row before it, so any change to history would show.
GET /payments/PAY-9F3A61C2B7D4/events
{ "payment_id": "PAY-9F3A61C2B7D4", "events": [
{ "seq": 1, "type": "payment.created", "at": "…", "actor": "merchant", "data": { … },
"prev_hash": null, "hash": "9c1f…" },
{ "seq": 2, "type": "checkout.opened", "actor": "student", "prev_hash": "9c1f…", "hash": "41ab…" },
{ "seq": 3, "type": "attempt.started", "attempt": 1, "data": { "method": "card", … } },
…
] }
Types: payment.created, checkout.opened, attempt.started, attempt.otp_sent, attempt.otp_rejected, attempt.succeeded, attempt.failed, attempt.abandoned, attempt.held, payment.paid, payment.expired, payment.cancelled, payment.refunded, webhook.sent, webhook.answered, note.added.
A row you read once always comes back with the same hash. You may store the hashes and compare them later. Card numbers, PINs, OTP codes and Qi account numbers are never in the ledger.
Webhooks
We POST to your webhook URL whenever a payment's status changes.
X-Ibt-Event-Id: evt_6f1c0a…
X-Ibt-Timestamp: 1764672067
X-Ibt-Signature: sha256=<hex HMAC-SHA256(webhook_secret, timestamp + "." + raw_body)>
{ "id": "evt_6f1c0a…", "type": "payment.paid", "created_at": "2026-12-02T10:41:07Z",
"data": { …the payment object… } }
Events: payment.paid, payment.expired, payment.cancelled, payment.refunded.
Verify before you trust it (Node.js)
function verifyIbtWebhook(headers, rawBody /* Buffer, before JSON parsing */) {
const ts = headers['x-ibt-timestamp'];
const given = (headers['x-ibt-signature'] || '').replace('sha256=', '');
const expected = crypto.createHmac('sha256', WEBHOOK_SECRET)
.update(`${ts}.`).update(rawBody).digest('hex');
const fresh = Math.abs(Date.now() / 1000 - Number(ts)) < 300;
return fresh && given.length === expected.length
&& crypto.timingSafeEqual(Buffer.from(given), Buffer.from(expected));
}
- Answer any
2xxwithin 10 seconds; do your work after answering. - Otherwise we retry after 1 min, 5 min, 30 min, 2 h, 6 h, 12 h and 24 h. After that the event is marked failed and we can resend it on request.
- The same event can arrive more than once. Store
idand ignore repeats. - Redirects are not followed. The URL must be HTTPS on a public address.
- If a webhook never arrives,
GET /payments/{id}gives the same answer.
Statuses & reasons
| Payment status | Meaning | Can change to |
|---|---|---|
pending | Waiting for the customer. A failed attempt leaves it here; the customer may try again. | paid, expired, cancelled |
paid | Money confirmed with the provider. Deliver the order. | refunded |
expired | The link's time ran out and no attempt was in progress. No money taken. | — |
cancelled | Cancelled by you. No money taken. | — |
refunded | The money went back to the customer. | — |
A status never moves backwards: a paid payment can never become pending again.
Attempt status: started, succeeded, failed, abandoned, held. Attempt reason: declined, cancelled_by_student, otp_failed, timed_out, gateway_error, late_payment.
held / late_payment means money reached a payment that had already closed. It is never applied to the order; we return it to the customer.
Errors
{ "error": { "code": "invalid_signature", "message": "the signature does not match" } }
| HTTP | code | What to do |
|---|---|---|
| 401 | invalid_signature, timestamp_out_of_range, unknown_key, replayed_request | Check the signing, your clock, and that you sign each request fresh. |
| 403 | ip_not_allowed, merchant_inactive | Call from a registered IP; contact us if your merchant is switched off. |
| 404 | not_found | Unknown id, or a payment that is not yours. |
| 409 | order_id_conflict, payment_in_progress, not_cancellable | See the message. |
| 422 | invalid_request, amount_out_of_range, return_url_not_allowed | The message names the field. |
| 429 | rate_limited | Wait for Retry-After seconds. |
| 5xx | server_error | Retry with a new signature; order_id makes it safe. |
Fees
You receive your amount in full. The customer pays it plus two fees, both shown to them before they pay:
service_fee = your agreed rate on amount (percent and/or fixed, with an optional minimum), rounded up
subtotal = amount + service_fee
method fee = the chosen method's fee on subtotal
total paid = subtotal + method fee
| Example | Card | ZainCash | Installments |
|---|---|---|---|
| Your amount | 250,000 | 250,000 | 250,000 |
| Service fee (example 2%) | 5,000 | 5,000 | 5,000 |
| Method fee (example) | 0 | 1,530 | 12,750 |
| Customer pays | 255,000 | 256,530 | 267,750 |
| You receive | 250,000 | 250,000 | 250,000 |
Rates in this example are illustrative; yours are in your agreement. The service fee is fixed when the payment is created; a later change of rates never reprices an open payment. Installments: the customer repays the provider over the plan, and the monthly figure shown includes the provider's own financing charge.
Refunds
- Refunds are made by Ibtiaath. Ask your account manager with the payment
id, the amount and the reason. - When it is done you receive
payment.refundedand the payment's status becomesrefunded. The ledger records who, when and why. - Card and ZainCash refunds go back to the card or wallet. Installment refunds are reversed with the provider.
- Whether fees are returned, and how a refund made after a settlement is recovered, follow your agreement.
Settlement التسوية
We collect your customers' payments and transfer what you are owed to your bank account, once per settlement period.
What you are owed for a period
owed = sum of amount for payments paid in the period
− sum of amount for those payments since refunded
± adjustments agreed in writing (e.g. a refund made after an earlier settlement)
Service fees and method fees are Ibtiaath's and are not part of what you are owed. A payment belongs to the period in which it was paid (paid_at, UTC).
The cycle
- Period closes on the schedule in your agreement.
- Statement is emailed to your finance contact: every payment in the period with its
id, yourorder_id,amount, fees, method and date, the refunds, and the total owed. - You check it against your own records (see Reconciliation). Raise any difference within the window in your agreement.
- Transfer of the total owed to your registered bank account, with the statement reference.
- Confirmation from your finance contact that the money arrived.
Settlement period, transfer day and dispute window are set in your agreement. Nothing is settled from test payments.
Reconciliation
List a period's paid payments yourself and compare them with the statement:
GET /api/v1/merchant/payments?status=paid&from=2026-12-01&to=2026-12-08&limit=100&offset=0
- Page with
offsetuntilhas_moreisfalse. - Also list
status=refundedfor the same period. - Match on
idand yourorder_id; compareamount. - Use
GET /payments/{id}/eventsfor the full story of any single payment.
Testing
Your staging key belongs to a test merchant. Its checkout shows two buttons, simulate a successful payment and simulate a failed payment, and opens no provider, so no money moves. Everything else is real: signing, the link, the ledger, the webhook and its retries. Test payments carry "test": true.
Cases to cover before going live
- Pay successfully; deliver only after the webhook or a status check.
- Fail once, then succeed on the same payment (two attempts).
- Let a link expire; create a new payment for the same
order_id. - Cancel an unpaid payment.
- Send the same create twice (same answer) and with a different amount (
409). - Make your webhook return
500once and check that the retry is handled once. - Reject a webhook with a wrong signature.
- Close the WebView mid-payment, then read the payment from your server.
Go-live checklist
- ☐ Secrets are on your server only, never in an app or page.
- ☐ Every request is signed fresh; your server clock is synced.
- ☐
order_idis unique per order and reused on retries. - ☐ Orders are delivered from the webhook or
GET /payments/{id}, never from the return URL. - ☐ The webhook verifies signature and timestamp, answers within 10 s, and ignores repeated event ids.
- ☐ The WebView allows JavaScript, cookies and navigation to other hosts, and closes on your
return_url. - ☐
expired,cancelledandrefundedare handled in your app and back office. - ☐ Production webhook URL and return URL prefixes are sent to us.
- ☐ Bank details confirmed for settlement.
- ☐ First real payment on each method checked on both sides.
Security
- Card details are entered on the bank's page and wallet PINs on ZainCash's page. They never reach Ibtiaath or you.
- All traffic is HTTPS. The checkout page cannot be framed, sends no referrer, loads nothing from other sites, and reaches only its own endpoints.
- Your API and webhook secrets are stored encrypted at rest on our side and shown to you once.
- Payment records cannot be edited or deleted; every change is a new ledger row, checked nightly.
- If a secret may have leaked, tell us at once: we revoke it and issue a new one.
Support
Your Ibtiaath account manager is your first contact for onboarding, keys, refunds and settlement. For a technical problem with a payment, always include the payment id (PAY-…), your order_id and the time, never a secret.
Ibtiaath Pay