Node.js SDK

@minnha/node — the server-side SDK. Use it from any backend (Express, Next.js, NestJS, Fastify, Hono, ...).

Install

bash
npm install @minnha/node

Initialize

ts
import { Minnha } from "@minnha/node";

const minnha = new Minnha(process.env.MINNHA_API_KEY!);

// or with options:
const minnha = new Minnha({
  apiKey: process.env.MINNHA_API_KEY!,
  baseUrl: "https://api.minnha.pay",   // optional
  timeoutMs: 30_000,                   // optional, default 30s
  maxRetries: 2,                       // optional, default 2
});

Resources

Sessions

ts
const session = await minnha.sessions.create({ amount: 100, currency: "SAR" });
await minnha.sessions.retrieve(token);
await minnha.sessions.list({ page: 0, size: 20 });

Transactions

ts
await minnha.transactions.list({ status: "SUCCESS" });
await minnha.transactions.retrieve(id);                 // { transaction, attempts }
await minnha.transactions.refund(id, { amount: 50 });
await minnha.transactions.capture(id);

// Auto-paginated iteration
for await (const tx of minnha.transactions.iterate({ status: "FAILED" })) {
  console.log(tx.id);
}

Customers

ts
await minnha.customers.create({ email: "c@x.com", name: "Customer" });
await minnha.customers.list();
await minnha.customers.retrieve(id);
await minnha.customers.delete(id);

Webhooks

ts
import { Minnha, MinnhaSignatureError } from "@minnha/node";

const event = Minnha.Webhooks.parse(rawBody, signatureHeader, webhookSecret);
// throws MinnhaSignatureError on bad signature

Errors

See Errors for the full hierarchy. The Node SDK retries 5xx / 429 automatically.

Idempotency

ts
await minnha.sessions.create(
  { amount: 100, currency: "SAR" },
  { idempotencyKey: "ord_123" }
);