One SDK. Every Iraqi payment gateway. Zero pain. ZainCash ยท FIB ยท AsiaCell Cash ยท FastPay ยท Qi Card ยท Switch โ unified API.
npm i iraq-pay
# or
pip install iraq-pay
# or
flutter pub add iraq_payูู ุจูุงุจุฉ ุฏูุน ุนุฑุงููุฉ ููุง:
- API ู ุฎุชูู (REST vs SOAP vs custom)
- ุชูุซูู ู ุชูุฑู
- ุตูุงุบุฉ ู ุฎุชููุฉ ููุฃุฑูุงู ูุงูุนู ูุงุช
- webhooks ู ุชุจุงููุฉ
- ุจูุฆุฉ sandbox ุบูุฑ ู ูุญุฏุฉ
ุงููุชูุฌุฉ: ุฃู ู ุทูุฑ ููุฑุฑ ูุฏุนู ู ุชุฌุฑู ุฃูุซุฑ ู ู ุจูุงุจุฉ โ 3 ุฃุณุงุจูุน ุดุบู + bugs ูุง ููุงูุฉ ููุง.
iraq-pay ูุญู ูุฐุง. SDK ูุงุญุฏ. API ู
ูุญุฏ. ูู ุงูุจูุงุจุงุช.
import { IraqPay } from "iraq-pay";
const pay = new IraqPay({
zaincash: { merchant_id: "...", secret: "..." },
fib: { client_id: "...", client_secret: "..." },
asiacell: { api_key: "..." },
fastpay: { merchant_code: "..." },
qi: { terminal_id: "..." },
});
// Same API for every gateway
const session = await pay.createPayment({
gateway: "zaincash", // or "fib", "asiacell", "fastpay", "qi"
amount: 50000, // in IQD (Iraqi Dinar)
currency: "IQD",
reference: "ORDER-12345",
customer: {
name: "ูุงุณู
ู
ุญู
ุฏ",
phone: "+9647763695936",
email: "customer@example.com",
},
redirect_url: "https://yoursite.com/thanks",
webhook_url: "https://yoursite.com/api/webhook",
});
console.log(session.payment_url); // Redirect customer here| Gateway | Type | Status | Sandbox |
|---|---|---|---|
| ZainCash | Mobile wallet | โ Production | โ |
| FIB (First Iraqi Bank) | Card + wallet | โ Production | โ |
| AsiaCell Cash | Mobile wallet | โ Production | โ |
| FastPay | Card + wallet | โ Production | โ |
| Qi Card | Government salaries + e-commerce | โ Production | |
| Switch | Visa/Mastercard via Iraqi switch | ๐ง Beta | โ |
| Nass Wallet | New mobile wallet | ๐ง Beta | โ |
We add new gateways quarterly. Request one.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Your App โ
โ (one SDK call โ gateway-agnostic) โ
โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโผโโโโโโโโโโโโโ
โ iraq-pay SDK โ
โ - Normalizes inputs โ
โ - Routes to gateway โ
โ - Validates response โ
โ - Handles webhooks โ
โ - Idempotency keys โ
โ - Retry policy โ
โโโโโโโโโโโโโฌโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโฌโโโโโโโโดโโโโโโโโฌโโโโโโโโโโโ
โผ โผ โผ โผ
โโโโโโโโโโโ โโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโ
โZainCash โ โ FIB โ... โFastPay โ โ Qi โ
โ API โ โ API โ โ API โ โ API โ
โโโโโโโโโโโ โโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโ
Each gateway has its own adapter under the hood. Your code never sees the gateway-specific quirks.
Every gateway sends webhooks differently. We unify them:
import { IraqPay } from "iraq-pay";
const pay = new IraqPay({ /* ... */ });
app.post("/api/webhook", async (req, res) => {
const event = pay.parseWebhook({
headers: req.headers,
body: req.body,
signature: req.headers["x-iraq-pay-signature"],
});
// Same event format regardless of source
switch (event.type) {
case "payment.completed":
await markOrderPaid(event.reference, event.amount);
break;
case "payment.failed":
await markOrderFailed(event.reference, event.failure_reason);
break;
case "payment.refunded":
await markOrderRefunded(event.reference, event.refund_amount);
break;
}
res.status(200).send("ok");
});Signature verification is automatic per-gateway.
// Refund
await pay.refund({
gateway: "fib",
payment_id: "pay_xyz",
amount: 25000, // Partial refund OK
reason: "Customer cancelled",
});
// Marketplace split (for multi-vendor stores)
await pay.createPayment({
gateway: "zaincash",
amount: 100000,
splits: [
{ recipient: "vendor_1", amount: 70000 }, // 70%
{ recipient: "vendor_2", amount: 25000 }, // 25%
{ recipient: "platform", amount: 5000 }, // 5% (your cut)
],
});
// Subscriptions (where supported)
await pay.createSubscription({
gateway: "fib",
plan: "monthly_50k",
customer_id: "user_123",
start_date: new Date(),
});Every gateway has a sandbox. We auto-route to sandbox when NODE_ENV=test:
const pay = new IraqPay({
mode: "sandbox", // or "production" or "auto"
// ...
});
// Use these test phone numbers for ZainCash sandbox:
// +9647712345671 โ always approves
// +9647712345672 โ always declines
// +9647712345673 โ timeout
// +9647712345674 โ 3D Secure requiredDon't want to integrate the SDK? Run our local control panel:
docker run -p 8080:8080 -v ~/.iraq-pay:/data ghcr.io/kasimmj/iraq-pay-dashboardOpen http://localhost:8080 and you get a beautiful Arabic+English dashboard with:
- ๐ Live transactions โ every payment as it happens
- ๐ธ One-click refunds โ no code needed
- ๐ Per-gateway analytics โ which converts best
- ๐ Webhook tester โ simulate callbacks
- ๐ ๏ธ Manual reconciliation โ match payments to orders
- ๐ค CSV export โ for accounting
- ๐ฎ๐ถ Full RTL Arabic โ for your finance team
Perfect for small shops, accountants, and customer support teams.
const stats = await pay.stats({
from: "2026-05-01",
to: "2026-05-31",
group_by: ["gateway", "currency"],
});
// Returns:
[
{ gateway: "zaincash", currency: "IQD", count: 124, total: 6_200_000, success_rate: 0.94 },
{ gateway: "fib", currency: "IQD", count: 87, total: 12_800_000, success_rate: 0.97 },
// ...
]npm install iraq-paypip install iraq-payfrom iraq_pay import IraqPay
pay = IraqPay(zaincash={"merchant_id": "...", "secret": "..."})
session = pay.create_payment(gateway="zaincash", amount=50000, ...)flutter pub add iraq_payfinal pay = IraqPay(
zaincash: ZainCashConfig(merchantId: '...', secret: '...'),
);
final session = await pay.createPayment(
gateway: Gateway.zaincash,
amount: 50000,
...
);composer require kasimmj/iraq-payAll four implementations expose the same API surface โ switch languages without re-learning.
- Every Iraqi e-commerce site reinvents this wheel
- Most existing wrappers are abandoned (last commit 2022)
- Documentation in Arabic is rare and often outdated
- This SDK is maintained, versioned, and tested in production (Solar iQ uses it across 6 cities)
We accept PRs for any registered Iraqi payment provider. To add one:
- Read docs/adding-a-gateway.md
- Implement the
GatewayAdapterinterface (8 methods) - Add tests against the gateway's sandbox
- Submit PR
We help with the API contracts if you have access to a gateway we don't.
MIT.
Star โญ if you've ever cursed at an Iraqi payment API.