Ibtiaath Pay
Merchant API v1
Getting started

Accept payments through Ibtiaath Pay

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.

You integrateOne signed REST API, one WebView, one webhook
MethodsBank card · ZainCash · Installments
CurrencyIraqi dinar (IQD), whole numbers
You receiveThe full amount you send us

Principles

  • You never handle card or wallet details. Card numbers, wallet PINs and OTP codes are entered on Ibtiaath's page or the provider's page. Your systems only see status, method and amounts.
  • Your amount is final. Apply your own discounts before sending the amount. You may send a record of them; we keep it but never deduct it.
  • Fees are added on top. The customer pays your amount, a service fee and the chosen method's fee. See Fees.
  • Every payment is a permanent record. Each attempt, result and notification is a row in the payment's ledger, which can only be added to. See The payment ledger.

Where to start

Getting started

What you send us

The technical details we need to set up your merchant, once for staging and once for production.

You can change these yourself in the merchant portal (partners.ibtiaath.com): return URL prefixes, webhook URL, smallest and largest payment, link lifetime and server IPs are under Settings; API keys and the webhook secret under Developers. The portal also lists every payment link and what your customer did with it.

ItemDetails
Webhook URLHTTPS on a public address, answering within 10 seconds. One URL per environment.REQUIRED
Return URL prefixesWhere the checkout sends the customer when done. Every return_url must start with one, e.g. https://app.example.com/pay/ or yourapp://pay/.REQUIRED
Display nameShown to your customers at the top of the checkout.REQUIRED
Technical contactReceives the keys and is contacted about incidents.REQUIRED
Server IP addressesOnly these addresses may use your key. Empty allows any address; the signature still protects every call.optional
Payment limitsSmallest and largest single payment.optional
Checkout link lifetimeHow long a link stays payable. Default 30 minutes.optional
Checkout languageArabic (default) or English; can also be set per payment.optional
Getting started

What we send you

Your credentials, one set per environment.

ItemUsed forKeep it
Key ID · ibk_…Identifies your key on every request (X-Ibt-Key).Server config
API secretSigns your requests. Shown once; we can only issue a new one.Server secret store only
Webhook secretVerifies the webhooks we send you.Server secret store only
API base and checkout hostSee Environments.Server config

Never put a secret in a mobile app or a web page. Anyone can extract it. Your app talks to your server; only your server talks to our API.

Key rotation

Keys rotate without downtime: we issue a second key, you switch to it, then we revoke the first. If a secret may have leaked, tell us at once and we revoke it.

Getting started

Environments

Staging for building and testing, production for your customers. Keys do not work across them.

StagingProduction
API basehttps://api.staging.ibtiaath.com/api/v1/merchanthttps://api.ibtiaath.com/api/v1/merchant
Checkout hosthttps://pay.staging.ibtiaath.comhttps://pay.ibtiaath.com
ZainCashSandbox: test wallets only, no money movesLive
Bank cardLive: real moneyLive
InstallmentsLive: real moneyLive

Only ZainCash is a sandbox on staging. Bank card and installment payments on staging are real and take real money. Test with ZainCash, or use the smallest amounts on the other methods.

Integration

How a payment runs

Your server talks to us twice and hears from us once. Your customer only ever sees the checkout and the provider's page.

Customer's app Your server Ibtiaath Pay Payment provider 1 · taps Pay 2 · POST /payments (signed) 3 · id + checkout_url 4 · checkout_url 5 · WebView opens the checkout 6 · customer pays (card + 3-D Secure, wallet PIN + OTP, or installment OTP) 7 · we confirm with the provider 8 · webhook payment.paid (signed) 9 · back to your return_url 10 · GET /payments/{id} (optional check)

Only step 7, our own check with the provider, marks a payment paid. The return to your app in step 9 is a hint for your screen, never proof of payment.

Integration

Signing requests

Every request carries three headers. There is no password or bearer token on the wire.

HEADERS
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)

Rules

  • METHOD in upper case. path_with_query exactly as sent, from /api/v1/merchant/…, including the query string.
  • raw_body is the exact bytes you send. With no body it is the empty string (SHA-256 e3b0c442…b855).
  • The timestamp must be within 5 minutes of real time. Keep your server clock synced.
  • Each signature is accepted once. To retry a request, sign it again.

Node.js

JAVASCRIPT
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(HOST + path, { method: 'POST', body,
  headers: ibtHeaders(KEY_ID, API_SECRET, 'POST', path, body) });

PHP

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

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'}
Payments API

Create a payment

Ask for a payment and get the checkout link to open for your customer.

POST/api/v1/merchant/payments

Request body

FieldTypeDescription
order_id REQUIREDstringYour id for the order, up to 100 characters (letters, digits, . _ - : /). The idempotency key.
amount REQUIREDintegerThe final amount you want to receive, whole IQD, within your limits.
currencystringIQD only.
customer.name REQUIREDstringShown on the checkout.
customer.email / phone ONE REQUIREDstringPhone as digits with an optional leading +.
customer.idstringYour id for the customer. Recommended.
product.name REQUIREDstringShown on the checkout. product.id is optional.
promoobjectused, code, discount_amount: a record of your own discount. Never deducted.
return_urlstringMust start with one of your registered prefixes.
localestringar (default) or en.
metadataobjectYour own JSON, up to 2,000 characters, returned unchanged.
REQUEST
{
  "order_id": "EMAC-2026-000123",
  "amount": 250000,
  "currency": "IQD",
  "customer": { "id": "stu_8841", "name": "Ali Hassan", "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"
}

Response

201 Created — the payment object, plus checkout_url and methods, what each method would cost right now.

RESPONSE
{
  "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_id again, while its payment is pending or paid, returns that payment (200) with the same checkout_url while it can still be used. Safe to retry after a timeout.
  • The same order_id with a different amount is refused: 409 order_id_conflict.
  • After a payment expires or is cancelled, the same order_id creates a new payment.
Payments API

Retrieve a payment

The source of truth for a payment's status, with every attempt the customer made.

GET/api/v1/merchant/payments/{id}
RESPONSE
{
  "id": "PAY-9F3A61C2B7D4",  "order_id": "EMAC-2026-000123",
  "status": "paid",  "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",  "paid_at": "2026-12-02T10:41:07Z",
  "customer": { … },  "product": { … },  "promo": { … },  "metadata": { … },
  "attempts": [
    { "no": 1, "method": "card", "total": 255000, "status": "failed", "reason": "declined" },
    { "no": 2, "method": "zaincash", "total": 256530, "status": "succeeded", "transaction_id": "TXN-4C1D09AB77E2" }
  ]
}

Fields

FieldDescription
amountWhat you asked for and are owed.
service_fee · subtotalOur fee, fixed at creation, and amount + fee.
gateway_fee · total_paidThe chosen method's fee, and what the customer paid. 0 until paid.
methodcard, zaincash or installments; null until paid.
transaction_idOur receipt number for the payment.
attemptsEvery try, with method, fee, total, status, reason and times. See Statuses.
Payments API

List payments

Find a payment by your own order id, or list a period for reconciliation.

GET/api/v1/merchant/payments?order_id=…
QueryDescription
order_idYour order id.
statuspending, paid, expired, cancelled.
from · toCreation dates (ISO date or date-time), to exclusive.
limit · offsetPage size (max 100) and start.
RESPONSE
{ "data": [ { …payment… }, … ], "has_more": false }
Payments API

Cancel a payment

Close an unpaid payment so its link can no longer be used.

POST/api/v1/merchant/payments/{id}/cancel
  • Returns the payment with status cancelled. Cancelling a cancelled payment returns the same answer.
  • Refused with 409 payment_in_progress while the customer is paying, so money can never land on a cancelled payment.
  • A paid payment cannot be cancelled.
Payments API

The payment ledger

One row for each thing that happened to a payment. Rows are only ever added: none is changed or deleted.

GET/api/v1/merchant/payments/{id}/events
RESPONSE
{ "payment_id": "PAY-9F3A61C2B7D4", "events": [
  { "seq": 1, "type": "payment.created", "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", … } }
] }

Event types

TypeWritten when
payment.createdYour create call is accepted.
checkout.openedThe customer opens the link.
attempt.startedThe customer picks a method and presses pay.
attempt.otp_sent · otp_rejectedInstallments only; never the code itself.
attempt.succeeded · failed · abandoned · heldThe attempt's outcome.
payment.paid · expired · cancelledThe payment's status changes.
webhook.sent · webhook.answeredEach webhook try, with the status your server answered.
note.addedIbtiaath staff add an explanation.

Each row carries the hash of the row before it. A row you read once always comes back with the same hash; store the hashes if you want to check that for yourself. Card numbers, PINs, OTP codes and Qi account numbers are never in the ledger.

Integration

Open the checkout

Open checkout_url exactly as received, in a WebView or the browser.

The part after # is a one-payment secret. It never reaches a 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 as return_url?payment_id=PAY-…&order_id=…&status=…
  • The link stays payable until the payment is paid, cancelled or expired (30 minutes by default).

The status on the return URL is for your screen only. Before you deliver anything, confirm with the webhook or GET /payments/{id}.

The checkout follows Ibtiaath's app design, in Arabic or English. It shows your display name, the product, your amount, one fee line and the total for the chosen method.

Integration

Payment methods

Which methods appear is set per merchant by Ibtiaath and returned in methods.

Bank cardVisa / Mastercard through Areeba, with 3-D Secure.
ZainCashWallet number, PIN and OTP on ZainCash's page.
InstallmentsQi Card (Aqsati): account number, plan, OTP. From 10,000 IQD.
  • A method outside its own limits for the amount is left out of methods.
  • One payment can be in progress at a time: once a method has taken the money, the others are refused.
  • A failed attempt leaves the payment pending; the customer may try again with any method.
Integration

Webhooks

We POST to your webhook URL whenever a payment's status changes.

REQUEST
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.

Verify the signature

JAVASCRIPT
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));
}

Delivery

  • Answer any 2xx within 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 can be resent on request.
  • The same event can arrive more than once. Store id and 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.
Integration

Statuses

A payment's status only ever moves forward. A paid payment can never become pending again.

StatusMeaningCan become
pendingWaiting for the customer. A failed attempt leaves it here.paid, expired, cancelled
paidMoney confirmed with the provider. Deliver the order.—
expiredThe link's time ran out with no attempt in progress. No money taken.—
cancelledCancelled by you. No money taken.—

Attempts

FieldValues
statusstarted, succeeded, failed, abandoned, held
reasondeclined, 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.

Integration

Errors

Every error has the same shape.

RESPONSE
{ "error": { "code": "invalid_signature", "message": "the signature does not match" } }
HTTPCodeWhat to do
401invalid_signature · timestamp_out_of_range · unknown_key · replayed_requestCheck the signing, your clock, and that each request is signed fresh.
403ip_not_allowed · merchant_inactiveCall from a registered IP; contact us if your merchant is switched off.
404not_foundUnknown id, or a payment that is not yours.
409order_id_conflict · payment_in_progress · not_cancellableSee the message.
422invalid_request · amount_out_of_range · return_url_not_allowedThe message names the field.
429rate_limitedWait Retry-After seconds.
5xxserver_errorRetry with a new signature; order_id makes it safe.
Money

Fees

You receive your amount in full. The customer pays it plus two fees, both shown before they pay.

CALCULATION
service_fee = your service fee rate on amount (percent and/or fixed, optional minimum), rounded up
subtotal    = amount + service_fee
method fee  = the chosen method's fee on subtotal
total paid  = subtotal + method fee

Example

CardZainCashInstallments
Your amount250,000250,000250,000
Service fee (example 2%)5,0005,0005,000
Method fee (example)01,53012,750
Customer pays255,000256,530267,750
You receive250,000250,000250,000

Rates here are illustrative. The fees for your merchant are returned in service_fee and methods on every payment. The service fee is fixed when the payment is created, so a later change of rates never reprices an open payment. For installments, the monthly figure shown to the customer includes the provider's own financing charge.

Launch

Testing

Build and test on staging. On staging, ZainCash runs on its sandbox; bank card and installments are live.

Bank card and installments on staging take real money. Use ZainCash for your tests, or the smallest amounts on the other methods.

ZainCash test wallets

On staging, choose ZainCash on the checkout and pay with any of these wallets. No money moves.

Wallet numberPINOTP
96478029995691111111111
96478297444321111111111
96478297444641111111111
96478297444741111111111

Cases to cover

  • Pay successfully; deliver only after the webhook or a status check.
  • Fail once (wrong OTP or cancel on ZainCash's page), then succeed on the same payment.
  • 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 500 once 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.
Launch

Go-live checklist

Every line must hold before we issue your production key.

  • Secrets are on your server only, never in an app or a page.
  • Every request is signed fresh; your server clock is synced.
  • order_id is 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 seconds, and ignores repeated event ids.
  • The WebView allows JavaScript, cookies and navigation to other hosts, and closes on your return_url.
  • expired and cancelled are handled in your app and back office.
  • Production webhook URL and return URL prefixes are sent to us.
  • A first real payment on each method is checked on both sides.
Launch

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 cannot be framed, sends no referrer, loads nothing from other sites and reaches only its own endpoints.
  • Your API and webhook secrets are 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.
Launch

Support

Your Ibtiaath technical contact is your first contact for keys and incidents.

For a problem with a payment, always include the payment id (PAY-…), your order_id and the time. Never send a secret.

© 2026 Ibtiaath · Ibtiaath Pay merchant documentation v1