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

# Instalasi

> Pasang MerchantId, verifikasi runtime, dan pahami format paket ESM/CommonJS.

## Memasang paket

```bash theme={null}
npm install merchantid
```

MerchantId tidak memiliki dependency runtime dan memakai `fetch` global. Node.js 18 atau runtime lain dengan Web Fetch API dapat menjalankan library.

<Note>
  Nama paket dan binary CLI adalah `merchantid`. Versi `0.1.0` sempat
  dipublikasikan dengan nama `merchid`; sejak `0.1.1` paket bernama
  `merchantid`. Jika Anda pernah memakai `merchid`, pasang ulang dengan `npm
      install merchantid` dan ganti perintah CLI dari `merchid` ke `merchantid`.
</Note>

## Impor

MerchantId adalah paket ESM dengan build CommonJS pendamping dan deklarasi tipe untuk keduanya.

<CodeGroup>
  ```ts ESM theme={null}
  import { MerchantId, GopayProvider, ShopeeProvider } from "merchantid";
  ```

  ```js CommonJS theme={null}
  const { MerchantId, GopayProvider, ShopeeProvider } = require("merchantid");
  ```
</CodeGroup>

Seluruh API publik diekspor dari entry tunggal `merchantid`. Tidak ada subpath import lain selain `merchantid/package.json`. Lihat [Referensi API](/api/overview) untuk daftar lengkap ekspor.

## Verifikasi runtime

Library membutuhkan `fetch` global. Node.js 18+ menyediakannya. Untuk runtime tanpa `fetch` global, atau untuk memakai client yang dipooling/diproxy, injeksikan implementasi sendiri lewat opsi `fetch` pada provider:

```ts theme={null}
import { GopayProvider } from "merchantid";
import { fetch as undiciFetch } from "undici";

const gopay = new GopayProvider({
  fetch: undiciFetch as typeof fetch,
});
```

Tanpa `fetch` global dan tanpa `fetch` kustom, konstruksi provider melempar `ConfigError` dengan pesan yang meminta upgrade Node atau injeksi implementasi.

## Kompatibilitas runtime

| Runtime                | Status           | Pola rekonsiliasi                              |
| ---------------------- | ---------------- | ---------------------------------------------- |
| Node.js 18+            | Diuji di CI      | `start()` atau scheduler dengan `tick()`       |
| Cloudflare Workers     | Belum diuji      | Cron/Alarm memanggil `tick()`                  |
| Vercel Edge, Deno, Bun | Belum diuji      | Scheduler platform memanggil `tick()`          |
| Browser                | Tidak dianjurkan | Jangan tempatkan kredensial merchant di client |

CI menjalankan Node 18 dan 24 di Linux serta Node 24 di Windows. Core dan API publik tidak mengimpor satu pun Node builtin: kriptografi memakai `globalThis.crypto` dengan fallback, dan `node:fs`, `node:os`, `node:path`, serta `node:readline/promises` hanya dipakai CLI. Lihat [Dukungan runtime](/troubleshooting/overview#dukungan-runtime).

## Langkah berikutnya

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/guide/quickstart">
    Login, buat pembayaran, deteksi settlement.
  </Card>

  <Card title="CLI" icon="terminal" href="/cli/overview">
    Login dan kelola sesi tanpa menulis kode.
  </Card>
</CardGroup>
