npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

iraqpay

v0.1.0

Published

Unified payment SDK for all Iraqi payment gateways — ZainCash, FIB, QiCard, NassPay, and more

Readme

IraqPay — Unified Payment SDK for Iraq

CI npm version License: MIT

One SDK for all Iraqi payment gateways. Stop writing separate integrations for each gateway.

| Gateway | Auth | Payment Flow | Refund | Status | |---------|------|-------------|--------|--------| | ZainCash | JWT (HS256) | Web redirect | Manual | Ready | | FIB | OAuth2 | QR code + deep links | API | Ready | | QiCard | Basic Auth | 3DS redirect | API | Ready | | NassPay | Bearer token | 3DS redirect | Manual | Ready | | COD | None | Tracking only | Manual | Ready |

Install

npm install iraqpay

Quick Start

import { IraqPay } from 'iraqpay';

const pay = new IraqPay({
  gateways: {
    zaincash: {
      msisdn: '9647XXXXXXXXX',
      merchantId: 'your_merchant_id',
      secret: 'your_secret',
    },
    fib: {
      clientId: 'your_client_id',
      clientSecret: 'your_client_secret',
    },
  },
  sandbox: true, // Use test environments
  language: 'ar', // 'ar' | 'en' | 'ku'
});

// Create a payment — same interface for every gateway
const payment = await pay.createPayment({
  gateway: 'zaincash',
  amount: 25000, // IQD (integer, no decimals)
  orderId: 'order_123',
  description: 'Product purchase',
  callbackUrl: 'https://myapp.com/payment/callback',
});

// Each gateway returns what it supports:
console.log(payment.redirectUrl); // ZainCash, QiCard, NassPay
console.log(payment.qrCode);     // FIB (base64 image)
console.log(payment.deepLinks);  // FIB (personal/business/corporate)

Check Payment Status

const status = await pay.getStatus(payment.id, 'zaincash');

if (status.status === 'paid') {
  console.log('Payment received!');
}

Handle Callbacks

// Express.js example
app.get('/payment/callback', async (req, res) => {
  // ZainCash sends JWT token as query parameter
  const event = await pay.verifyCallback(req.query.token, 'zaincash');

  if (event.status === 'paid') {
    // Update your order
  }
});

app.post('/payment/webhook', async (req, res) => {
  // FIB sends POST with { id, status }
  const event = await pay.verifyCallback(req.body, 'fib');

  if (event.status === 'paid') {
    // Update your order
  }
  res.sendStatus(200);
});

All Gateways

ZainCash

const pay = new IraqPay({
  gateways: {
    zaincash: {
      msisdn: '9647XXXXXXXXX',     // Merchant wallet number
      merchantId: 'your_id',        // From ZainCash
      secret: 'your_secret',        // From ZainCash
    },
  },
  sandbox: true,
});

const payment = await pay.createPayment({
  gateway: 'zaincash',
  amount: 5000,
  orderId: 'zc_001',
  callbackUrl: 'https://myapp.com/callback',
});

// Redirect user to payment page
res.redirect(payment.redirectUrl);

FIB (First Iraqi Bank)

const pay = new IraqPay({
  gateways: {
    fib: {
      clientId: 'your_client_id',
      clientSecret: 'your_client_secret',
    },
  },
  sandbox: true,
});

const payment = await pay.createPayment({
  gateway: 'fib',
  amount: 10000,
  currency: 'IQD', // Also supports 'USD'
  orderId: 'fib_001',
  description: 'Order payment',
  callbackUrl: 'https://myapp.com/webhook',
});

// Show QR code to user
console.log(payment.qrCode);       // base64 image
console.log(payment.readableCode); // manual entry code

// Or redirect to FIB app
console.log(payment.deepLinks?.personal); // fib://...

// Refund (FIB supports this)
await pay.refund(payment.id, 'fib');

QiCard

const pay = new IraqPay({
  gateways: {
    qicard: {
      username: 'your_username',
      password: 'your_password',
      terminalId: 'your_terminal_id',
    },
  },
  sandbox: true,
});

const payment = await pay.createPayment({
  gateway: 'qicard',
  amount: 50000,
  orderId: 'qi_001',
  successUrl: 'https://myapp.com/success',
  callbackUrl: 'https://myapp.com/notify',
  customerInfo: {
    firstName: 'Ahmed',
    lastName: 'Ali',
    phone: '9647XXXXXXXXX',
    email: '[email protected]',
  },
});

// Redirect to 3DS payment page
res.redirect(payment.redirectUrl);

NassPay

const pay = new IraqPay({
  gateways: {
    nasspay: {
      username: 'merchant_user',
      password: 'merchant_pass',
    },
  },
  sandbox: true,
});

const payment = await pay.createPayment({
  gateway: 'nasspay',
  amount: 15000,
  orderId: 'nass_001',
  description: 'Electronics purchase',
  successUrl: 'https://myapp.com/success',
  callbackUrl: 'https://myapp.com/notify',
});

// Redirect to 3DS page
res.redirect(payment.redirectUrl);

Cash-on-Delivery

const pay = new IraqPay({
  gateways: { cod: {} },
});

const payment = await pay.createPayment({
  gateway: 'cod',
  amount: 30000,
  orderId: 'cod_001',
});

// When driver collects cash:
const codGateway = pay.getGateway('cod');
await codGateway.markPaid(payment.id);

Multi-Gateway Setup

const pay = new IraqPay({
  gateways: {
    zaincash: { /* ... */ },
    fib: { /* ... */ },
    qicard: { /* ... */ },
    nasspay: { /* ... */ },
    cod: {},
  },
  sandbox: true,
  defaultGateway: 'fib',
});

// Uses default gateway (FIB)
await pay.createPayment({ amount: 5000, orderId: 'auto_001' });

// Or specify per-payment
await pay.createPayment({ gateway: 'zaincash', amount: 5000, orderId: 'zc_002' });

Error Handling

import { IraqPayError, GatewayNotConfiguredError, PaymentFailedError } from 'iraqpay';

try {
  await pay.createPayment({ gateway: 'zaincash', amount: 100, orderId: 'test' });
} catch (err) {
  if (err instanceof GatewayNotConfiguredError) {
    console.log('Gateway not configured:', err.gateway);
  } else if (err instanceof PaymentFailedError) {
    console.log('Payment failed:', err.message, err.raw);
  } else if (err instanceof IraqPayError) {
    console.log('IraqPay error:', err.code, err.message);
  }
}

Gateway Comparison

| Feature | ZainCash | FIB | QiCard | NassPay | COD | |---------|----------|-----|--------|---------|-----| | Payment redirect | Yes | No | Yes (3DS) | Yes (3DS) | No | | QR code | No | Yes | No | No | No | | Mobile deep links | No | Yes | No | No | No | | Webhooks | No | Yes (POST) | Yes (POST) | Yes (POST) | No | | Refund API | No | Yes | Yes | No | No | | Cancel API | Limited | Yes | Yes | No | Yes | | USD support | No | Yes | No | No | N/A | | Sandbox | Yes | Yes | Yes | Yes | N/A |

Testing

# Unit tests (no network required)
npm test

# Integration tests with live sandbox
ZAINCASH_LIVE=1 npm test

Changelog

See CHANGELOG.md for version history.

License

MIT

Contributing

Pull requests welcome. For major changes, please open an issue first.

Docs

Links