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

egypt-pay

v1.0.1

Published

Unified payment gateway library for Egyptian payment providers (Kashier, Paymob)

Readme

egypt-pay

Unified payment gateway library for Egyptian payment providers.

Supports: Kashier, Paymob
Runtime: Node 18+, Cloudflare Workers, Deno, Bun
Dependencies: None (uses Web Crypto API)

egypt-pay

Installation

npm install egypt-pay

Quick Start

import { createGateway } from "egypt-pay";

// ── Kashier ──────────────────────────────────────────────
const kashier = createGateway("kashier", {
  merchantId: "MID-123-456",
  apiKey: "your-api-key",
  secretKey: "your-secret-key",
  mode: "test", // "test" | "live"
});

// ── Paymob ───────────────────────────────────────────────
const paymob = createGateway("paymob", {
  secretKey: "egy_sk_test_...",
  publicKey: "egy_pk_test_...",
  integrationId: "5357002",
  hmacSecret: "YOUR_HMAC_SECRET",
});

// ── Create Session (same interface for both) ─────────────
const session = await kashier.createSession({
  orderId: "ORD-001",
  amount: 150.0,
  customer: {
    name: "Ahmed Mohamed",
    email: "[email protected]",
    phone: "01012345678",
  },
  redirectUrl: "https://yoursite.com/payment/callback",
  webhookUrl: "https://yoursite.com/api/webhooks/payment",
  description: "Order #001",
  locale: "ar",
});

// Redirect customer to:
console.log(session.paymentUrl);

Webhook Verification

// Kashier webhook
app.post("/api/webhooks/kashier", async (req, res) => {
  const signature = req.headers["x-kashier-signature"];
  const event = await kashier.verifyWebhook(req.body, signature);

  if (event && event.status === "paid") {
    // Update order status
    await markOrderPaid(event.orderId, event.transactionId);
  }

  res.status(200).send("OK");
});

// Paymob webhook
app.post("/api/webhooks/paymob", async (req, res) => {
  const hmac = req.query.hmac || req.body.hmac;
  const event = await paymob.verifyWebhook(req.body, hmac);

  if (event && event.status === "paid") {
    await markOrderPaid(event.orderId, event.transactionId);
  }

  res.status(200).send("OK");
});

API Reference

createGateway(provider, config)

Creates a gateway instance.

| Provider | Config | |----------|--------| | "kashier" | { merchantId, apiKey, secretKey, mode } | | "paymob" | { secretKey, publicKey, integrationId, hmacSecret } |

gateway.createSession(params)

| Param | Type | Required | Description | |-------|------|----------|-------------| | orderId | string | Yes | Your internal order ID | | amount | number | Yes | Amount in EGP (e.g. 150.00) | | customer | object | Yes | { name, email, phone?, reference? } | | redirectUrl | string | Yes | URL after payment | | webhookUrl | string | No | Server-to-server notification URL | | description | string | No | Payment description | | locale | "ar" | "en" | No | Display language | | allowedMethods | string | No | e.g. "card,wallet" | | items | array | No | Line items | | metadata | object | No | Extra key-value pairs |

Returns: { sessionId, paymentUrl, raw }

gateway.verifyWebhook(body, signature)

Verifies and parses a webhook payload.

Returns: { orderId, status, transactionId, amount, currency, method, card, raw } or throws WebhookVerificationError.

Payment Status

| Status | Description | |--------|-------------| | "paid" | Payment successful | | "failed" | Payment failed | | "pending" | Awaiting confirmation | | "refunded" | Payment refunded | | "voided" | Payment voided |

Direct Import

You can also import adapters directly:

import { KashierGateway } from "egypt-pay/kashier";
import { PaymobGateway } from "egypt-pay/paymob";

Error Handling

import { PaymentError, WebhookVerificationError } from "egypt-pay";

try {
  const session = await gateway.createSession(params);
} catch (err) {
  if (err instanceof PaymentError) {
    console.error(err.provider, err.statusCode, err.responseBody);
  }
}

License

MIT