> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kori.ml/llms.txt
> Use this file to discover all available pages before exploring further.

# SDKs

> Official client libraries for the Kori Merchant API.

The SDKs handle the token exchange, retries, pagination, typed errors and webhook
verification, so your code only deals with payments.

| Language | Package | Status |
| - | - | - |
| Node.js / TypeScript | [`@korisdk/node`](https://www.npmjs.com/package/@korisdk/node) | Available |
| PHP | — | Planned |

Prefer plain HTTP? Every guide in these docs shows the raw requests too.

## Node.js / TypeScript

```bash theme={null}
npm install @korisdk/node
```

Node 18 or later, ESM or CommonJS, no runtime dependencies. Run it on your **server**
only: it holds your API secret.

```javascript theme={null}
import { Kori } from "@korisdk/node";

const kori = new Kori({
  apiKey: process.env.KORI_API_KEY,
  apiSecret: process.env.KORI_API_SECRET,
  environment: "sandbox", // "live" when you go to production
  scopes: ["pay", "balance"],
});

const payment = await kori.payments.collect({
  amount: 5000,
  payment_method: "OrangeMoney",
  customer_phone: "+22370000000",
  reference: "order_1024",
});
// payment.status === "pending": wait for the payment_received webhook.
```

### What it does for you

* **Authentication.** It exchanges your key and secret for a token on the first call, reuses
  it, and renews it before it expires. You never call `/auth` yourself.
* **Scopes.** Pass `scopes` with what this service needs. A missing one throws
  `KoriPermissionError`, and `error.requiredScopes` tells you which scope to add.
* **Pagination.** `await kori.payouts.list()` returns the first page.
  `for await (const p of kori.payouts.list())` walks every page.
* **Errors.** Each failure throws a typed error (`KoriValidationError`,
  `KoriConflictError`, `KoriRateLimitError`, and so on) that carries the `requestId`.
  Quote that ID to support.
* **Safe retries.** Reads are retried after network errors and 5xx. `payments.collect`,
  `payments.deposit` and `payouts.create` are **never** repeated after a timeout, because
  the customer may already have been prompted. Look the payment up by your `reference`
  instead.
* **Webhooks.** `kori.webhooks.verify(rawBody, signature, secret)` checks the signature and
  returns the typed event. See [Webhooks](https://docs.kori.ml/en/webhooks.md#verify-the-signature).

### Waiting for a payment

```javascript theme={null}
const result = await kori.payments.waitForResult("order_1024", { timeoutMs: 120000 });
if (result.state === "success") {
  // paid
}
```

This polls [payment status](https://docs.kori.ml/en/payment-status.md). Use it only while a customer is
waiting on screen. Webhooks remain the reliable signal.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.