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

# Mode Kasir

> Buat sesi kasir hosted. Pelanggan atau kasir memilih metode pembayaran sendiri di layar kasir.

Buat sesi kasir hosted: merchant hanya mengirim nominal dan `returnUrl`, lalu kasir atau pelanggan bebas memilih metode pembayaran di layar kasir.

Merchant tidak perlu menentukan channel atau metode secara spesifik (seperti `channel: "qris"`). Sistem menampilkan semua metode aktif di layar kasir: QRIS, VA Bank, maupun E-Wallet.

### Body

| Parameter | Tipe | Wajib | Deskripsi |
| - | - | - | - |
| storeId | string | Ya | ID toko Anda |
| amount | number | Ya | Nominal dalam Rupiah (tanpa desimal) |
| returnUrl | string | Ya | URL redirect setelah bayar selesai |
| customerName | string | Tidak | Nama customer |
| customerEmail | string | Tidak | Email customer |
| customerPhone | string | Tidak | Nomor HP customer |
| callbackUrl | string | Tidak | URL webhook notifikasi status bayar |

### Contoh request

`POST /api/v1/cashier/create`

```json Body theme={null}
{
  "storeId": "380193d2be145a3d469aca03eeada9f8",
  "amount": 150000,
  "returnUrl": "https://toko-anda.com/checkout/finish?order_id=INV-99201",
  "customerName": "Budi Santoso",
  "customerEmail": "budi@pelanggan.com",
  "customerPhone": "081234567890",
  "callbackUrl": "https://toko-anda.com/api/payment-callback"
}
```

```bash cURL theme={null}
curl -X POST http://localhost:5173/api/v1/cashier/create \
  -H "Content-Type: application/json" \
  -d '{
    "storeId": "380193d2be145a3d469aca03eeada9f8",
    "amount": 150000,
    "returnUrl": "https://toko-anda.com/checkout/finish?order_id=INV-99201",
    "customerName": "Budi Santoso",
    "customerEmail": "budi@pelanggan.com",
    "customerPhone": "081234567890",
    "callbackUrl": "https://toko-anda.com/api/payment-callback"
  }'
```

```javascript JavaScript theme={null}
const response = await fetch("http://localhost:5173/api/v1/cashier/create", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    storeId: "380193d2be145a3d469aca03eeada9f8",
    amount: 150000,
    returnUrl: "https://toko-anda.com/checkout/finish?order_id=INV-99201",
    customerName: "Budi Santoso",
    customerEmail: "budi@pelanggan.com",
    customerPhone: "081234567890",
    callbackUrl: "https://toko-anda.com/api/payment-callback",
  }),
});

const { data } = await response.json();
window.location.href = data.payUrl;
```

```php PHP theme={null}
<?php
$payload = [
    "storeId" => "380193d2be145a3d469aca03eeada9f8",
    "amount" => 150000,
    "returnUrl" => "https://toko-anda.com/checkout/finish?order_id=INV-99201",
    "customerName" => "Budi Santoso",
    "customerEmail" => "budi@pelanggan.com",
    "customerPhone" => "081234567890",
    "callbackUrl" => "https://toko-anda.com/api/payment-callback",
];

$ch = curl_init("http://localhost:5173/api/v1/cashier/create");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
    CURLOPT_POSTFIELDS => json_encode($payload),
    CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true)["data"];
header("Location: " . $data["payUrl"]);
```

```javascript Node.js theme={null}
import axios from "axios";

const { data: res } = await axios.post("http://localhost:5173/api/v1/cashier/create", {
  storeId: "380193d2be145a3d469aca03eeada9f8",
  amount: 150000,
  returnUrl: "https://toko-anda.com/checkout/finish?order_id=INV-99201",
  customerName: "Budi Santoso",
  customerEmail: "budi@pelanggan.com",
  customerPhone: "081234567890",
  callbackUrl: "https://toko-anda.com/api/payment-callback",
});

console.log(res.data.orderId, res.data.payUrl);
```

```python Python theme={null}
import requests

payload = {
    "storeId": "380193d2be145a3d469aca03eeada9f8",
    "amount": 150000,
    "returnUrl": "https://toko-anda.com/checkout/finish?order_id=INV-99201",
    "customerName": "Budi Santoso",
    "customerEmail": "budi@pelanggan.com",
    "customerPhone": "081234567890",
    "callbackUrl": "https://toko-anda.com/api/payment-callback",
}

res = requests.post("http://localhost:5173/api/v1/cashier/create", json=payload)
data = res.json()["data"]
print(data["orderId"], data["payUrl"])
```

```go Golang theme={null}
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
)

func main() {
	payload := map[string]any{
		"storeId":       "380193d2be145a3d469aca03eeada9f8",
		"amount":        150000,
		"returnUrl":     "https://toko-anda.com/checkout/finish?order_id=INV-99201",
		"customerName":  "Budi Santoso",
		"customerEmail": "budi@pelanggan.com",
		"customerPhone": "081234567890",
		"callbackUrl":   "https://toko-anda.com/api/payment-callback",
	}
	body, _ := json.Marshal(payload)

	resp, err := http.Post(
		"http://localhost:5173/api/v1/cashier/create",
		"application/json",
		bytes.NewReader(body),
	)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	var result map[string]any
	json.NewDecoder(resp.Body).Decode(&result)
	data := result["data"].(map[string]any)
	fmt.Println(data["orderId"], data["payUrl"])
}
```

```rust Rust theme={null}
// Cargo.toml: reqwest = { version = "0.12", features = ["json"] }, serde_json = "1", tokio = { version = "1", features = ["full"] }
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
    let payload = json!({
        "storeId": "380193d2be145a3d469aca03eeada9f8",
        "amount": 150000,
        "returnUrl": "https://toko-anda.com/checkout/finish?order_id=INV-99201",
        "customerName": "Budi Santoso",
        "customerEmail": "budi@pelanggan.com",
        "customerPhone": "081234567890",
        "callbackUrl": "https://toko-anda.com/api/payment-callback"
    });

    let res: Value = reqwest::Client::new()
        .post("http://localhost:5173/api/v1/cashier/create")
        .json(&payload)
        .send()
        .await?
        .json()
        .await?;

    println!("{} {}", res["data"]["orderId"], res["data"]["payUrl"]);
    Ok(())
}
```

### Contoh response

Arahkan pelanggan ke `payUrl` untuk membuka layar kasir.

```json theme={null}
{
  "success": true,
  "data": {
    "orderId": "CSH-20261103001",
    "amount": 150000,
    "totalAmount": 150000,
    "status": "pending",
    "payUrl": "http://localhost:5173/cashier/pay/CSH-20261103001",
    "returnUrl": "https://toko-anda.com/checkout/finish?order_id=INV-99201",
    "expiredAt": "2026-11-03T16:00:00.000Z"
  }
}
```

> [!NOTE]
>
> Metode pembayaran di layar kasir dikonfigurasi melalui halaman **Mode Kasir → Metode Pembayaran Kasir**. Anda dapat mengaktifkan atau menonaktifkan metode tertentu tanpa mengubah request API.


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