# Referensi API Jakmall Mitra (hasil capture lab)

**Diperbarui:** 2026-06-04  
**Sumber mentah:** `data/api-captures/2026-06-04/*.jsonl`  
**Dashboard:** http://localhost/mitraonline/captures.php  
**Registry endpoint:** `data/api-endpoint-registry.json`

Dokumen ini merangkum data penting yang sudah direkam — supaya tidak perlu membuka puluhan file JSONL saat coding Fase B/C.

---

## 1. Autentikasi & lab

| Item | Lokasi / cara |
|------|----------------|
| Cookie sesi | `data/jakmall-cookies.txt` (gitignore) |
| Sinkron dari Chrome | ekstensi `extension/sync-login` → `api/set-cookies.php` |
| Rekam API | ekstensi `extension/api-capture` → `api/capture-request.php` |
| Base URL Jakmall | `https://www.jakmall.com` |
| Header | Cookie lab + CSRF seperti browser (belum diimplementasi di client PHP) |

Tanpa cookie valid, semua `_api/*` dan `/mitra/checkout/*` mengembalikan login/error.

---

## 2. Konstanta akun & toko (sesi capture)

> Website brand: **MitraJual** (`docs/BRAND-MITRAJUAL.md`). **TomboAti** di bawah = channel Jakmall/TikTok, bukan nama website.

Gunakan sebagai **default config** bot; bisa berubah jika ganti gudang/toko.

| Nama | Nilai | Keterangan |
|------|--------|------------|
| `affiliate_store_id` (checkout / invoice store) | `11f15f1bd443fc6ea628d68412f86113` | Toko dipakai di form checkout dropship |
| `warehouse_id` / `warehouse_code` | `11eeb42a07f7065ebe98d6928c833f6d` | Gudang **PICK N GO**, Surabaya |
| `warehouse.city_id` | `11e5e2e9d2bce63ab2d006ed45375133` | Kota Surabaya |
| `sub_district_code` (alamat contoh) | `11e5e2e9df393d0a947806ed45375133` | Kecamatan penerima (Wonocolo area) |
| `drop_ship_fee` gudang | `5000` | Biaya dropship per order (dari response products) |

### Channel katalog (TomboAti & terkait)

| Channel | `store_profile_id` (catalogue list) | Marketplace |
|---------|-------------------------------------|-------------|
| TomboAti Nasional | `11f14a31f4eb754a9002fa5f4cdc7774` | TikTok Shop |
| Mitra Syafaat | `11f14bfe8143f09eba2ce63f3c922c99` | Shopee |
| ASAMALL | `11f15788d3ee948a83d382ad381b2b81` | TikTok Shop |

File: `api-mitra-store-profile-catalogue-list.jsonl`

---

## 3. Mapping SKU (contoh teruji checkout)

| SKU display (input products) | `sku_code` / `code` (numeric) | `product_id` (expeditions) | `price_hash` | `product_page_snapshot_id` | Harga | Berat |
|------------------------------|-------------------------------|---------------------------|--------------|---------------------------|-------|-------|
| **ILMS04BK** | `1624699265651` | `8506908383062` | `e3tdB2` | `xkpoEw` | 17400 | 150 g |
| **OMSK20RE** | `7353257642325` | `3636546977334` | `vWte8j` | `2DJvq7` | 6000 | 30 g |

**Alur:** `POST checkout/products` dengan `product: ["ILMS04BK"]` → response berisi `code`, `price_hash`, `product_page_snapshot_id` → wajib dipakai di `item[]` langkah fee/checkout.

File: `mitra-checkout-products.jsonl`

---

## 4. Checkout dropship — chain lengkap (TERCAPTURE)

Halaman: https://www.jakmall.com/mitra/checkout  
Model bisnis: **pelanggan bayar di website Anda** → fulfillment + **Jakwallet** di Jakmall.

```mermaid
sequenceDiagram
  participant UI as Browser checkout
  participant API as jakmall.com/mitra/checkout

  UI->>API: POST /products
  UI->>API: POST /expeditions
  Note over UI,API: Isi alamat → expeditions dengan address
  UI->>API: POST /fee
  UI->>API: POST /payment-validation
  UI->>API: POST /checkout
  API-->>UI: url pay.jakmall.com
```

### 4.1 `POST /mitra/checkout/products`

**Request contoh:**
```json
{
  "product": ["ILMS04BK"],
  "warehouse_id": "11eeb42a07f7065ebe98d6928c833f6d"
}
```

**Response penting (per SKU):** `code`, `product_id`, `price`, `price_hash`, `product_page_snapshot_id`, `warehouse.drop_ship_fee`.

File: `mitra-checkout-products.jsonl`

---

### 4.2 `POST /mitra/checkout/expeditions`

**Tanpa alamat** — daftar kurir (harga ongkir di options sering `0` sampai alamat diisi).

**Request inti:**
```json
{
  "warehouse_code": "11eeb42a07f7065ebe98d6928c833f6d",
  "cart": { "total_price": 17400, "total_weight": 150 },
  "marketplace_source": {
    "name": "lainnya",
    "invoiceCode": "09874657",
    "store_id": "11f15f1bd443fc6ea628d68412f86113",
    "platform": null
  },
  "product_ids": ["8506908383062"],
  "must_insurance": false,
  "selected_shipping": {
    "delivery_type_code": null,
    "awb": null,
    "delivery_type_raw": null
  },
  "force_marketplace": 0,
  "is_sof": 0,
  "is_cashless": 0,
  "is_autofill": 0
}
```

**Dengan alamat** — tambahkan `address`:
```json
{
  "receiver": "Tono",
  "phone_number": "08973907999",
  "address": "Warung Tombo Ati wonocolo sebelah barat stasiun sepamjang",
  "postal_code": "61257",
  "sub_district_code": "11e5e2e9df393d0a947806ed45375133",
  "latitude": "",
  "longitude": "",
  "map_address": null
}
```

**Kurir contoh:** `JNE_YES`, `JNE_REG`, `JET_REG`, `SICEPAT_REG`, `GO_SEND_SAME_DAY`, dll. — lihat `options[].id` di response.

File: `mitra-checkout-expeditions.jsonl`

---

### 4.3 `POST /mitra/checkout/fee`

**Response sukses:** body plain text angka ongkir, contoh `"2200"` (= Rp 2.200), `Content-Type: text/html`.

**Payload final** (sama struktur untuk `payment-validation` dan `checkout`, tanpa field ekstra di fee):

```json
{
  "drop_shipper_name": "Alfatih",
  "drop_shipper_phone_number": "0811255165",
  "marketplace_source": "lainnya",
  "marketplace_code": "09874657",
  "affiliate_store_id": "11f15f1bd443fc6ea628d68412f86113",
  "warehouse_id": "11eeb42a07f7065ebe98d6928c833f6d",
  "address": {
    "receiver": "Tono",
    "phone_number": "08973907999",
    "address": "Warung Tombo Ati wonocolo sebelah barat stasiun sepamjang",
    "postal_code": "61257",
    "sub_district_code": "11e5e2e9df393d0a947806ed45375133",
    "latitude": "",
    "longitude": "",
    "map_address": null
  },
  "item": [{
    "sku_code": "1624699265651",
    "quantity": 1,
    "product_page_snapshot_id": "xkpoEw",
    "price_hash": "e3tdB2"
  }],
  "shipping": {
    "delivery_type_code": "JNE_YES",
    "delivery_type_sub": null,
    "delivery_tracking_code": null,
    "jwt": null,
    "delivery_insurance": true,
    "delivery_cashless": false
  },
  "autofill_type": 2,
  "force_marketplace": 0,
  "cod_amount": null,
  "is_cod": null,
  "autofill_jwt": null
}
```

File: `mitra-checkout-fee.jsonl` (baris `status: 200`)

---

### 4.4 `POST /mitra/checkout/payment-validation`

Request = payload fee + **`"marketplace_platform": ""`**.

**Response sukses:** konfirmasi produk, harga, gudang — `errors: []`.

File: `mitra-checkout-payment-validation.jsonl`

---

### 4.5 `POST /mitra/checkout` (buat order + redirect bayar)

Request sama seperti payment-validation.

**Response sukses (200):**
```json
{
  "url": "https://pay.jakmall.com/fc698957aa8f446fbadfa45204148827?t=ad&v=1"
}
```

Buka URL → bayar **Jakwallet** (langkah browser; belum ada capture callback terpisah di lab).

File: `mitra-checkout.jsonl`

---

### 4.6 Estimasi total (order sukses ILMS04BK + JNE YES)

| Komponen | Nilai (Rp) |
|----------|------------|
| Harga produk | 17.400 |
| Drop ship fee | 5.000 |
| Ongkir (`/fee`) | 2.200 |
| Asuransi JNE (UI, dari expeditions) | ~5.034 (opsional `delivery_insurance`) |

**Catatan:** `marketplace_source` di UI = **"lainnya"**; field API = `marketplace_source: "lainnya"` + **`marketplace_code`** = kode invoice / nomor order Anda.

---

## 5. Aturan validasi (dari error capture)

| Error | Code | Penyebab | Solusi bot |
|-------|------|----------|------------|
| Telepon pengirim dan penerima harus berbeda | `422-FV` / `drop_shipper_phone_number` | `drop_shipper_phone_number` = `address.phone_number` | Pakai HP toko vs HP customer |
| Kode Invoice sudah pernah digunakan | `422-CSORII-01` | `marketplace_code` duplikat | Generate invoice unik per order (UUID / nomor web) |

Contoh gagal: `mitra-checkout-fee.jsonl` (422), `mitra-checkout.jsonl` (422 invoice `999999`).

---

## 6. API lain yang sudah direkam

### Katalog toko

| Method | Path | File capture |
|--------|------|----------------|
| GET | `/_api/mitra/store-profile/catalogue/list` | `api-mitra-store-profile-catalogue-list.jsonl` |
| GET | `/_api/mitra/store-profile/catalogue/products` | `api-mitra-store-profile-catalogue-products.jsonl` |
| GET | `/_api/mitra/store-profile/catalogue/filter` | `api-mitra-store-profile-catalogue-filter.jsonl` |
| GET | `/_api/mitra/store-profile/catalogue/sync/status` | `api-mitra-store-profile-catalogue-sync-status.jsonl` |

### Kelola SKU channel

| Method | Path | File capture |
|--------|------|----------------|
| GET | `/_api/affiliate/store-profiles/manage/sku/list` | `api-affiliate-store-profiles-manage-sku-list.jsonl` (besar) |
| GET | `/_api/affiliate/store-profiles/manage/sku/filter` | `api-affiliate-store-profiles-manage-sku-filter.jsonl` |

**Belum capture:** `POST .../manage/sku/batch/edit` (toggle otomatis/manual).

### Pesanan marketplace (TikTok / Shopee)

| Method | Path | File capture |
|--------|------|----------------|
| GET | `/_api/affiliate/purchase-history/tab` | `api-affiliate-purchase-history-tab.jsonl` |
| GET | `/_api/affiliate/purchase-history/filter` | `api-affiliate-purchase-history-filter.jsonl` |
| GET | `/_api/affiliate/purchase-history/order/list` | `api-affiliate-purchase-history-order-list.jsonl` |

**Order TikTok real terekam (2026-06-04 02:24):** id `JWqjz1BJ2L`, total Rp 72.310 — lihat `data/reference/order-tiktok-marketplace-contoh.json` dan **`docs/ORDER-TIKTOK-MARKETPLACE.md`**.

**Sudah capture proses (2026-06-04 02:29):** `payment-method`, `deadline-check`, `order/confirm` (202) — lihat `data/reference/tiktok-order-process-contoh.json`.

**Belum capture:** `request-to-pickup` (tab Atur Pickup / Pengiriman).


### Checkout helper

| Method | Path |
|--------|------|
| GET | `/_api/sub-district/{code}/postal-code` |
| GET | `/_api/mitra/checkout/store-profiles` |
| POST | `/_api/mitra/marketplace/dropship-validation/check` |

---

## 7. Contoh JSON siap pakai (bot)

Salinan payload **sukses** untuk copy ke PHP/client:

`data/reference/checkout-dropship-contoh-sukses.json`

---

## 8. Perbedaan alur (ingat)

| Alur | URL | Kapan |
|------|-----|--------|
| **Checkout dropship** | `/mitra/checkout` | Order dari **website brand** / manual dropship |
| **Purchase history marketplace** | `/mitra/purchase-history?tab=marketplace_order` | Order **masuk dari TikTok/Shopee** yang disinkron Jakmall |

Website Anda → hampir selalu **checkout dropship**, bukan tab marketplace.

---

## 9. Langkah coding berikutnya (Fase B)

1. `lib/jakmall-api-client.php` — curl + cookie file + CSRF
2. Parser: products → expeditions → fee → validation → checkout
3. Map order website → `marketplace_code` unik + SKU display
4. Queue + approval sebelum `POST /checkout` & buka `pay.jakmall.com`

Lihat juga: `docs/ROADMAP-OTOMASI.md`, `docs/JAKMALL-PETA-LENGKAP.md`.

---

## 10. Indeks file capture per modul

```
data/api-captures/2026-06-04/
├── mitra-checkout-products.jsonl      ← langkah 1
├── mitra-checkout-expeditions.jsonl   ← langkah 2
├── mitra-checkout-fee.jsonl           ← langkah 3
├── mitra-checkout-payment-validation.jsonl
├── mitra-checkout.jsonl               ← langkah 5 bayar
├── api-mitra-store-profile-catalogue-*.jsonl
├── api-affiliate-store-profiles-manage-sku-*.jsonl
└── api-affiliate-purchase-history-*.jsonl
```

**Total sesi:** 48 file JSONL, registry ~40+ endpoint unik.
