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

# Scalev (payment)

> Payment gateway Indonesia untuk enrollment dan checkout.

**Scalev** menangani pembayaran kursus (e-payment, transfer, webhook status). Dev lokal bisa pakai `PAYMENT_PROVIDER=manual` tanpa Scalev.

**Dashboard:** [app.scalev.id](https://app.scalev.id)\
**Docs:** [docs.scalev.com](https://docs.scalev.com/id/dev-pendahuluan) · [developers.scalev.id](https://developers.scalev.id)

## Env di project

```bash theme={null}
PAYMENT_PROVIDER=scalev          # atau manual untuk dev
SCALEV_API_KEY=sk_...
SCALEV_WEBHOOK_SECRET=...
SCALEV_STORE_UNIQUE_ID=store_...
SCALEV_VARIANT_UNIQUE_ID=variant_...           # opsional per produk
SCALEV_BUNDLE_PRICE_OPTION_UNIQUE_ID=bpo_...   # opsional bundle
SCALEV_BASE_URL=https://api.scalev.com
```

## Setup

<Steps>
  <Step title="Akun bisnis Scalev">
    Daftar / login [app.scalev.id](https://app.scalev.id) — setup toko (store) dan produk/variant harga.
  </Step>

  <Step title="API key bisnis">
    Dashboard developer → buat **Business API key** (bearer token).\
    Docs auth: `Authorization: Bearer <token>` untuk route `/v3/...`
  </Step>

  <Step title="Ambil store unique id">
    Dari API list store atau dashboard — masukkan ke `SCALEV_STORE_UNIQUE_ID`
  </Step>

  <Step title="Webhook">
    1. Di Scalev, subscribe event: `order.payment_status_changed`, `order.status_changed`, dll.
    2. URL webhook production: `https://app.sertifikasitrainer.com/api/...` (endpoint webhook di API)
    3. Simpan secret ke `SCALEV_WEBHOOK_SECRET` — verifikasi signature di handler

    Docs: [Webhook events](https://docs.scalev.com/en/webhook-events)
  </Step>

  <Step title="Mapping variant/bundle">
    Setiap tier/kelas di TrainerHub perlu `variant_unique_id` atau `bundle_price_option_unique_id` yang match produk di Scalev.
  </Step>

  <Step title="Dev tanpa Scalev">
    ```bash theme={null}
    # .env.development.local
    PAYMENT_PROVIDER=manual
    MANUAL_PAYMENT_URL=https://...
    ```

    `./thub env merge` → checkout manual tanpa hit API Scalev.
  </Step>
</Steps>

## Alur order (ringkas)

```mermaid theme={null}
flowchart LR
  user[Peserta checkout] --> api[API TrainerHub]
  api --> scalev[Scalev create order]
  scalev --> pay[Halaman pembayaran]
  pay --> webhook[Webhook ke API]
  webhook --> enroll[Enrollment aktif]
```

Contoh URL pembayaran setelah order dibuat:

```
https://app.scalev.id/order/public/<secret_slug>/success
```

Docs: [Membuat order](https://developers.scalev.id/docs/membuat-order) · [API v3 pendahuluan](https://docs.scalev.com/id/dev-pendahuluan)

## Troubleshooting

| Masalah                        | Solusi                                                                                                           |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------- |
| Pembayaran tidak update        | Cek webhook URL + `SCALEV_WEBHOOK_SECRET`                                                                        |
| 401 ke API                     | `SCALEV_API_KEY` invalid atau expired                                                                            |
| Harga minimum error            | Konfigurasi tier di admin + mapping variant                                                                      |
| Dev error Scalev               | Override `PAYMENT_PROVIDER=manual` di dev                                                                        |
| Ganti API key / DB baru        | Tier masih pegang store lama → `./thub scalev resync` — lihat [DB baru + Scalev resync](/guides/fresh-db-scalev) |
| `Not Found` saat ensure-scalev | `SCALEV_STORE_UNIQUE_ID` di tier ≠ toko di key baru — resync                                                     |
