Ibtiaath Pay Merchant integration · v1 · December 2026
Merchant documentation

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.

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

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 من التسجيل حتى التسوية

  1. Agreement. Commercial terms are agreed: our service fee, which payment methods you offer, payment limits, and the settlement schedule.
  2. You send us your details. Company, contacts, URLs and bank account. The full list is in What you send us.
  3. We set you up on staging. You receive a test key, a webhook secret and the staging URLs. Test payments move no money.
  4. You integrate and test. Create payments, open the checkout, handle the webhook, cover every status. Run the go-live checklist.
  5. Review. We look at a few of your test payments and webhook answers together with you.
  6. 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.
  7. Live. Your customers pay. You fulfil orders from the webhook or the status call.
  8. 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

ItemWhy we need it
Legal company name and registration numberThe agreement and the settlement statements are issued to it.Required
Display nameShown to your customers at the top of the checkout, e.g. "EMAC".Required
What you sell and typical amountsSets your minimum and maximum payment, and which methods fit (installments start at 10,000 IQD).Required
Expected monthly volumeCapacity and limits.Recommended

People

ContactFor
Business contactTerms, fees, disputes.Required
Technical contactIntegration, key delivery, incidents. Receives the keys.Required
Finance contactSettlement statements and transfers.Required

Technical

ItemDetails
Webhook URL (staging and production)HTTPS, 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 you send must start with one of these, e.g. https://app.example.com/pay/ or your app scheme yourapp://pay/.Required
Server IP addressesOnly these addresses may use your key. Leave empty to allow any address (the signature still protects every call).Optional
Payment limitsSmallest and largest single payment you want to accept.Optional
Checkout link lifetimeHow long a link stays payable. Default 30 minutes.Optional
Checkout languageArabic (default) or English; can also be chosen per payment.Optional

Settlement

ItemDetails
Bank name and branchWhere settlements are paid.Required
Account holder nameMust match the legal company name.Required
Account number / IBANSent in writing from your finance contact; confirmed by a call before the first transfer.Required
Statement emailWhere 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

ItemUsed forKeep where
Key ID, e.g. ibk_test_… / ibk_live_…Identifies your key on every request (X-Ibt-Key).Server config
API secretSigns your requests. Shown once; we cannot show it again, only issue a new one.Server secret store only
Webhook secretVerifies the webhooks we send you.Server secret store only
API base URL and checkout hostSee 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 basehttps://api.staging.ibtiaath.com/api/v1/merchanthttps://api.ibtiaath.com/api/v1/merchant
Checkout hosthttps://pay.staging.ibtiaath.comhttps://pay.ibtiaath.com
Key prefixibk_test_ibk_live_
MoneyNone: test payments are completed with a simulate buttonReal

Keys and secrets are different per environment. A staging key does not work in production, and the reverse.

How a payment runs

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 (step 9) is a hint for your screen, never proof of payment.

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)
  • METHOD in upper case. path_with_query exactly as sent, starting at /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 (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" }
}
FieldRules
order_idRequiredYour own id for the order, up to 100 characters (letters, digits, . _ - : /). It is the idempotency key.
amountRequiredThe final amount you want to receive. Whole IQD, within your limits.
currencyIQD only.
customer.nameRequiredShown on the checkout.
customer.email / customer.phoneOne requiredPhone as digits with optional leading +.
customer.idRecommendedYour id for the customer. Lets us keep one record per customer.
product.nameRequiredShown on the checkout. product.id is optional.
promoA record of your own discount. Never deducted.
return_urlMust start with one of your registered prefixes.
localear (default) or en.
metadataYour 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_id again, while its payment is pending or paid, returns that same 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.

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 as
    return_url?payment_id=PAY-…&order_id=…&status=paid|pending|expired|cancelled
  • That status is for your screen only. Before you deliver anything, confirm with the webhook or GET /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

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.

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

CallWhat 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}/eventsThe payment's full ledger.
POST /payments/{id}/cancelCancel 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 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 we can resend it 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.

Statuses & reasons

Payment statusMeaningCan change to
pendingWaiting for the customer. A failed attempt leaves it here; the customer may try again.paid, expired, cancelled
paidMoney confirmed with the provider. Deliver the order.refunded
expiredThe link's time ran out and no attempt was in progress. No money taken.—
cancelledCancelled by you. No money taken.—
refundedThe 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" } }
HTTPcodeWhat to do
401invalid_signature, timestamp_out_of_range, unknown_key, replayed_requestCheck the signing, your clock, and that you sign each request 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 for Retry-After seconds.
5xxserver_errorRetry 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
ExampleCardZainCashInstallments
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 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.refunded and the payment's status becomes refunded. 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

  1. Period closes on the schedule in your agreement.
  2. Statement is emailed to your finance contact: every payment in the period with its id, your order_id, amount, fees, method and date, the refunds, and the total owed.
  3. You check it against your own records (see Reconciliation). Raise any difference within the window in your agreement.
  4. Transfer of the total owed to your registered bank account, with the statement reference.
  5. 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 offset until has_more is false.
  • Also list status=refunded for the same period.
  • Match on id and your order_id; compare amount.
  • Use GET /payments/{id}/events for 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 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.

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_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 s, and ignores repeated event ids.
  • ☐ The WebView allows JavaScript, cookies and navigation to other hosts, and closes on your return_url.
  • ☐ expired, cancelled and refunded are 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.