เอกสาร API
เชื่อมต่อระบบเว็บไซต์ของคุณกับเราในฐานะซัพพลายเออร์สินค้า H2H
เข้าสู่ระบบเพื่อรับ API Keyแนะนำ
คำขอทั้งหมดใช้เมธอด POST กับ JSON body Base URL endpoint:
Content-Type: application/json
การยืนยันตัวตน & Signature
ทุกคำขอต้องรวม api_id, api_key, และ signature ใน JSON body Signature คำนวณโดยใช้สูตร MD5
signature = HMAC-SHA256(
METHOD + "|" + PATH + "|" + timestamp + "|" + nonce,
api_key
)$apiId = 'API_ID_ANDA';
$apiKey = 'API_KEY_ANDA';
$method = 'POST';
$path = '/api/v1/profile'; // path LENGKAP dari base_url('api/v1')
$timestamp = time(); // unix timestamp (detik)
$nonce = bin2hex(random_bytes(16)); // string acak unik, min 8 karakter
$canonical = $method . '|' . $path . '|' . $timestamp . '|' . $nonce;
$signature = hash_hmac('sha256', $canonical, $apiKey);
$payload = [
'api_id' => $apiId,
'timestamp' => $timestamp,
'nonce' => $nonce,
'signature' => $signature,
// ...field lain (order_id, service_id, dst)
];timestamp (±300 detik dari waktu server) dan nonce (unik, tidak boleh dipakai ulang) wajib dikirim. Tiap request butuh signature berbeda. Skema lama md5(api_id + api_key) sudah tidak didukung.{
"api_id": "YOUR_API_ID",
"timestamp": 1700000000,
"nonce": "a1b2c3d4e5f6",
"signature": "HMAC-SHA256(POST|/api/v1/profile|1700000000|a1b2c3d4e5f6, api_key)"
}ตรวจสอบโปรไฟล์ / ยอดเงิน
ดึงข้อมูลบัญชี reseller: ชื่อผู้ใช้ ยอดเงิน และระดับราคา (บทบาท)
{
"api_id": "YOUR_API_ID",
"timestamp": 1700000000,
"nonce": "a1b2c3d4e5f6",
"signature": "HMAC-SHA256(POST|/api/v1/profile|1700000000|a1b2c3d4e5f6, api_key)"
}{
"status": true,
"msg": "ดึงข้อมูลโปรไฟล์สำเร็จ",
"data": {
"username": "resellerku",
"balance": "150000",
"role": "Gold"
}
}รายการบริการ (Price List)
ดึงสินค้าทั้งหมดพร้อมราคาตามระดับของคุณ (Basic / Gold / Platinum) ใช้ id เป็น service_id เมื่อสั่งซื้อ
| พารามิเตอร์ | ประเภท | คำอธิบาย |
|---|---|---|
api_id * | string | การยืนยันตัวตน & Signature |
timestamp * | integer | Unix timestamp (detik), ±300 detik dari waktu server. |
nonce * | string | String acak unik (min 8 karakter), tidak boleh dipakai ulang. |
signature * | string | HMAC-SHA256(METHOD|PATH|timestamp|nonce, api_key) |
region | string | Opsional. Filter hasil ke 1 region saja. Bisa diisi nama ("Indonesia") atau kode ("ID"), tidak case-sensitive. Kalau dikosongkan, semua region dikembalikan sekaligus. Alias: negara. |
{
"api_id": "YOUR_API_ID",
"timestamp": 1700000000,
"nonce": "a1b2c3d4e5f6",
"signature": "HMAC-SHA256(POST|/api/v1/service|1700000000|a1b2c3d4e5f6, api_key)",
"region": "Indonesia"
}[
{
"status": true,
"msg": "ดึงข้อมูลบริการสำเร็จ",
"data": {
"id": "101",
"game": "Mobile Legends",
"game_display": "Mobile Legends (Indonesia)",
"region_code": "ID",
"region_name": "Indonesia",
"nama_layanan": "86 Diamonds",
"negara": "ID",
"harga": {
"regular": "21500",
"basic": "21000",
"gold": "20500",
"platinum": "20000"
},
"status": "available"
}
}
]harga berisi 4 tingkatan harga sesuai role akun reseller Anda: regular (akun tanpa subscription aktif), basic, gold, dan platinum. Harga yang dibebankan saat order (endpoint /order) otomatis mengikuti role akun Anda saat ini — lihat field role pada respons /profile di atas. negara berisi kode region produk (ID, MY, PH, SG, TH, …), diturunkan dari Master Type yang terkait dengan produk (produk.tipe → product_types → master_types.negara).Field baru — disarankan dipakai untuk integrasi baru:
•
game_display — nama game yang sudah termasuk region, siap tampil langsung sebagai judul/brand di listing Anda (mis. "Mobile Legends (Indonesia)"). Kalau region belum terdeteksi untuk suatu produk, nilainya sama dengan game (tanpa suffix).•
region_code — kode ISO region ("ID", "MY", dst), sama isinya dengan negara. Bisa null kalau region belum terdeteksi.•
region_name — nama region dalam bentuk terbaca manusia ("Indonesia"), sesuai penamaan Master Type yang admin atur sendiri di panel Bybanana.Field
game tetap dipertahankan apa adanya (nama game polos, tanpa suffix region) untuk kompatibilitas mundur — integrasi lama tidak akan rusak. Kalau ingin listing game Anda otomatis terpisah per region (mis. "Mobile Legends (Indonesia)" dan "Mobile Legends (Malaysia)" sebagai 2 entri berbeda), kelompokkan produk berdasarkan game_display, bukan game. สร้างคำสั่งซื้อ
สร้างธุรกรรมใหม่ ยอดเงินจะถูกหักโดยอัตโนมัติตามระดับราคาของคุณ order_id สร้างโดยระบบของคุณและต้องไม่ซ้ำกัน
| พารามิเตอร์ | ประเภท | คำอธิบาย |
|---|---|---|
order_id * | string | รหัสธุรกรรมที่ไม่ซ้ำจากระบบของคุณ |
service_id * | string | รหัสบริการ (จาก endpoint /service) |
target_id * | string | รหัสผู้ใช้ / เลขหมายที่ปลายทาง |
target_server | string | โซน / เซิร์ฟเวอร์ (ถ้ามี) |
{
"api_id": "YOUR_API_ID",
"timestamp": 1700000000,
"nonce": "a1b2c3d4e5f6",
"signature": "HMAC-SHA256(POST|/api/v1/order|1700000000|a1b2c3d4e5f6, api_key)",
"order_id": "TRX-1700000001",
"service_id": "101",
"target_id": "123456789",
"target_server": "2001"
}{
"status": true,
"msg": "สั่งซื้อสำเร็จ! คำสั่งซื้อกำลังดำเนินการ",
"data": {
"order_id": "TRX-1700000001",
"nama_layanan": "86 Diamonds",
"service_id": "101",
"target_id": "123456789",
"target_server": "2001",
"status": "Proses",
"note": ""
}
}{
"status": false,
"msg": "order_id wajib diisi"
}{
"status": false,
"msg": "order_id sudah tersedia pada sistem kami",
"data": { "status": "error" }
}{
"status": false,
"msg": "service_id tidak ditemukan"
}{
"status": false,
"msg": "Saldo anda tidak mencukupi"
}ตรวจสอบสถานะธุรกรรม
ตรวจสอบสถานะปัจจุบันของธุรกรรมโดยใช้ order_id
| พารามิเตอร์ | ประเภท | คำอธิบาย |
|---|---|---|
order_id * | string | รหัสธุรกรรมที่ต้องการตรวจสอบ |
{
"api_id": "YOUR_API_ID",
"timestamp": 1700000000,
"nonce": "a1b2c3d4e5f6",
"signature": "HMAC-SHA256(POST|/api/v1/status|1700000000|a1b2c3d4e5f6, api_key)",
"order_id": "TRX-1700000001"
}{
"status": true,
"msg": "ดึงรายละเอียดธุรกรรมสำเร็จ",
"data": {
"order_id": "TRX-1700000001",
"status": "Sukses",
"note": "SN: 1234567890"
}
}ตรวจสอบ Nickname
ตรวจสอบ User ID เกมเพื่อรับชื่อเล่นของเจ้าของบัญชีก่อนสั่งซื้อ
code, id และ zone การตอบกลับจะถูกส่งต่อตามที่ได้รับจากผู้ให้บริการ nickname{
"code": "mlbb",
"id": "123456789",
"zone": "2001"
}Callback / Webhook
เมื่อสถานะคำสั่งซื้อเปลี่ยน (เช่น จาก Processing เป็น Success / Failed) ระบบของเราจะส่ง POST JSON ไปยัง Callback URL ที่คุณตั้งค่าในเมนูการเชื่อมต่อ API โดยอัตโนมัติ
POST {Callback URL Anda}
Content-Type: application/json
X-Signature: md5(api_id + order_id + status + webhook_secret)
{
"event": "order.status",
"order_id": "TRX-1700000001",
"service_id": "101",
"product": "86 Diamonds",
"status": "Sukses",
"note": "SN: 1234567890",
"sn": "SN: 1234567890",
"target_id": "123456789",
"target_server": "2001",
"price": 20500,
"timestamp": 1700000123,
"signature": "md5(api_id + order_id + status + webhook_secret)"
}$payload = json_decode(file_get_contents('php://input'), true);
$expected = md5($api_id . $payload['order_id'] . $payload['status'] . $webhook_secret);
if ($_SERVER['HTTP_X_SIGNATURE'] === $expected) {
// valid — update status order di sistem Anda
http_response_code(200);
echo 'OK';
}รายการสถานะธุรกรรม
สถานะที่อาจปรากฏในฟิลด์ status: