> ## 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.

# Quickstart

> Dari login sampai mendeteksi pembayaran pertama, untuk GoPay dan Shopee.

Halaman ini membawa Anda dari nol sampai pembayaran pertama yang terdeteksi. Cara tercepat mencoba adalah lewat CLI; integrasi kode ada di bawahnya.

<Warning>
  Setiap langkah di sini memakai API provider live. Pengiriman OTP, discovery,
  dan rekonsiliasi mengirim request nyata. Gunakan hanya akun merchant milik
  Anda sendiri.
</Warning>

## Jalur CLI (paling cepat)

<Steps>
  <Step title="Login">
    ```bash theme={null}
    npx merchantid login gopay
    ```

    CLI meminta nomor telepon dan OTP, lalu menyimpan sesi ke `~/.merchantid/config.json`. Untuk Shopee, `npx merchantid login shopee` juga meminta password akun.
  </Step>

  <Step title="Periksa status">
    ```bash theme={null}
    npx merchantid whoami
    ```

    Menampilkan provider default, jumlah merchant, dan apakah QRIS statis sudah terikat - semua ter-redaksi.
  </Step>

  <Step title="Pilih merchant dan QRIS">
    ```bash theme={null}
    npx merchantid merchants gopay
    npx merchantid set-merchant G000000001 --provider gopay
    ```

    Untuk Shopee, ikat QRIS statis secara manual dengan `npx merchantid set-qris shopee` setelah store dipilih.
  </Step>
</Steps>

Lihat [Ikhtisar CLI](/cli/overview) untuk seluruh perintah.

## Jalur kode: GoPay

GoPay menemukan QRIS statis dari profil outlet, jadi Anda tidak perlu menyediakannya manual.

```ts theme={null}
import { GopayProvider } from "merchantid";

const gopay = new GopayProvider({
  merchantId: "G000000001",
  session: sessionFromSecretStore, // hasil login sebelumnya
  onTokenRefreshed: async (session) => {
    await saveSecret("gopay-session", session);
  },
});

const payments = gopay.payments();
payments.on("paid", (payment) => {
  console.log("lunas", payment.reference, payment.uniqueAmount);
});
payments.on("expired", (payment) => {
  console.log("kedaluwarsa", payment.reference);
});
payments.start();

const payment = await gopay.createPayment({
  amount: 10_000,
  reference: "order-42",
});

console.log(payment.uniqueAmount); // 10001, pembeli harus membayar persis
await displayQrLocally(payment.qrString); // jangan tulis payload QRIS mentah ke log
```

Untuk mendapatkan sesi pertama kali lewat kode, lihat [Login GoPay](/gopay/login).

## Jalur kode: Shopee

Shopee memakai OTP fetch-only dan QRIS statis manual yang terikat ke store.

```ts theme={null}
import { ShopeeProvider } from "merchantid";

const shopee = new ShopeeProvider({
  session: sessionFromSecretStore,
  staticQris: qrisFromSecretStore.payload,
  staticQrisScope: qrisFromSecretStore.scope,
  onSessionUpdated: async (session) => {
    await saveSecret("shopee-session", session);
  },
});

const payment = await shopee.createPayment({
  amount: 30_000,
  reference: "order-shopee-17",
});

const result = await shopee.payments().tick();
console.log(result.paid, result.expired);
```

Untuk login OTP dari awal dan binding QRIS, lihat [Login Shopee](/shopee/login) dan [Pembayaran Shopee](/shopee/payments).

## Polling vs tick manual

`start()` memulai timer background. Untuk Worker, Edge, Lambda, atau proses tanpa timer persisten, jangan gunakan `start()`. Panggil `tick()` dari scheduler platform:

```ts theme={null}
const { paid, expired } = await gopay.payments().tick();
```

Satu `tick()` menjalankan satu putaran rekonsiliasi: menarik feed, menyelesaikan yang cocok, lalu menandai kedaluwarsa yang sudah lewat masa berlaku. Lihat [Model pembayaran](/concepts/payments).

## Langkah berikutnya

<CardGroup cols={2}>
  <Card title="Konsep inti" icon="diagram-project" href="/guide/concepts">
    Kenapa nominal unik, scope, dan grace window penting.
  </Card>

  <Card title="Model pembayaran" icon="money-bill-transfer" href="/concepts/payments">
    Siklus lengkap create sampai settle/expire.
  </Card>

  <Card title="GoPay Merchant" icon="wallet" href="/gopay/overview">
    Login, merchant, dan pembayaran GoPay.
  </Card>

  <Card title="Shopee Merchant" icon="bag-shopping" href="/shopee/overview">
    OTP, store, QRIS, dan sesi Shopee.
  </Card>
</CardGroup>
