REST API

Dokumentasi API Topup Game

Referensi endpoint dibuat dengan layout responsif ala Swagger. Semua contoh memakai placeholder aman dan base URL frontend agar dokumentasi tidak mengarah ke domain backend.

Base URL
https://topup.ferdiananda.web.id/api
Header umum
Accept: application/json
X-API-KEY: <api_key>
Endpoint publik
Menampilkan 5 dari 5 endpoint publik.

Autentikasi

Gunakan skema autentikasi sesuai endpoint. Jangan pernah menaruh secret atau API key asli di frontend publik.

X-API-KEY

Public REST

Dipakai untuk katalog publik, pembuatan order, detail invoice, dan polling status pembayaran.

Accept: application/json
X-API-KEY: <server-api-key>
Format sukses
{
  "success": true,
  "message": "Request berhasil.",
  "data": {}
}
Format error
{
  "success": false,
  "message": "Validasi gagal.",
  "error_code": "VALIDATION_ERROR",
  "errors": {}
}
Response JSON

Semua endpoint direkomendasikan mengirim header Accept: application/json agar response error maupun sukses konsisten.

Katalog Publik

Endpoint untuk membaca daftar game dan route detail game yang tersedia untuk publik.

Request
URL lengkap
https://topup.ferdiananda.web.id/api/games
Header
NamaTipeWajibDeskripsiContoh
AcceptstringYaGunakan application/json agar response selalu dikembalikan dalam format JSON.application/json
X-API-KEYstringYaAPI key publik yang diverifikasi oleh ApiKeyMiddleware untuk seluruh route public API.server-api-key
Contoh request
curl -X GET 'https://topup.ferdiananda.web.id/api/games' \
  -H 'Accept: application/json' \
  -H 'X-API-KEY: <server-api-key>'
Response
Status code
200
Daftar game berhasil dibaca
401
X-API-KEY tidak valid atau tidak dikirim
Contoh response sukses
{
  "success": true,
  "games": [
    {
      "id": 11,
      "image": "https://example.com/storage/games/mobile-legends.png",
      "banner": "https://example.com/storage/games/mobile-legends-banner.png",
      "title": "Mobile Legends",
      "developers": "Moonton",
      "brand": "MLBB",
      "category_id": 1,
      "slug": "mobile-legends",
      "description": "Top up diamond Mobile Legends.",
      "status": true,
      "populer": true,
      "sort": 1,
      "category": {
        "id": 1,
        "title": "MOBA"
      }
    }
  ],
  "populerGames": [
    {
      "id": 11,
      "image": "https://example.com/storage/games/mobile-legends.png",
      "banner": "https://example.com/storage/games/mobile-legends-banner.png",
      "title": "Mobile Legends",
      "developers": "Moonton",
      "brand": "MLBB",
      "category_id": 1,
      "slug": "mobile-legends",
      "description": "Top up diamond Mobile Legends.",
      "status": true,
      "populer": true,
      "sort": 1
    }
  ]
}
Contoh response error
Unauthorized
401
{
  "message": "Unauthorized"
}

Order & Invoice

Endpoint untuk membuat transaksi dan memantau invoice pembayaran.

Request
URL lengkap
https://topup.ferdiananda.web.id/api/order
Header
NamaTipeWajibDeskripsiContoh
AcceptstringYaGunakan application/json agar response selalu dikembalikan dalam format JSON.application/json
X-API-KEYstringYaAPI key publik yang diverifikasi oleh ApiKeyMiddleware untuk seluruh route public API.server-api-key
Body request
NamaTipeWajibDeskripsiContoh
idstringYaUser ID atau game ID target transaksi.12345678
serverstringTidakServer ID bila game memerlukannya.2012
gamestringYaSlug game yang aktif.mobile-legends
product_idintegerYaID produk yang dipilih.901
payment_method_idintegerYaID metode pembayaran yang dipilih.12
emailstringTidakEmail pemesan.[email protected]
whatsappstringYaNomor WhatsApp pemesan.081234567890
nicknamestringTidakNickname game bila tersedia.FerdiML
promo_codestringTidakKode promo yang ingin diterapkan.RAMADAN10
quantityintegerTidakJumlah item. Default 1.2
Catatan implementasi
  • Field game harus berisi slug game aktif, bukan title game.
  • Gunakan orderId pada response untuk membuka detail invoice dan polling status pembayaran.
  • Jika payload dasar tidak valid, Laravel validation akan mengembalikan response 422 dengan field message dan errors.
Contoh request
curl -X POST 'https://topup.ferdiananda.web.id/api/order' \
  -H 'Accept: application/json' \
  -H 'X-API-KEY: <server-api-key>' \
  -H 'Content-Type: application/json' \
  -d '{"id":"12345678","server":"2012","game":"mobile-legends","product_id":901,"payment_method_id":12,"email":"[email protected]","whatsapp":"081234567890","nickname":"FerdiML","promo_code":"RAMADAN10","quantity":2}'
Response
Status code
201
Order berhasil dibuat
404
Game, produk, atau metode pembayaran tidak ditemukan
422
Produk tidak sesuai game, promo tidak valid, atau payload tidak lolos validasi
500
Gagal membuat transaksi pembayaran atau menyimpan order
Contoh response sukses
{
  "success": true,
  "message": "Pesanan berhasil dibuat.",
  "orderId": "INV-20260329093000-ABCDEFGH",
  "data": {
    "order_id": "INV-20260329093000-ABCDEFGH",
    "payment_status": "UNPAID",
    "buy_status": "Pending",
    "payment_url": "https://gateway.example/pay/INV-20260329093000-ABCDEFGH",
    "payment_code": "INV-20260329093000-ABCDEFGH",
    "payment_reference": "INV-20260329093000-ABCDEFGH",
    "qr_url": null,
    "expired_at": "2026-03-29T10:00:00+07:00",
    "quantity": 2,
    "total_price": 40000,
    "pricing": {
      "quantity": 2,
      "has_promo": true,
      "promo_code": "RAMADAN10",
      "unit_price_before_promo": 22000,
      "unit_discount": 2000,
      "unit_price_after_promo": 20000,
      "subtotal_before_promo": 44000,
      "promo_discount": 4000,
      "subtotal_after_promo": 40000,
      "payment_fee": 0,
      "unique_code": 0,
      "total_price": 40000
    }
  }
}
Contoh response error
Produk tidak sesuai game
422
{
  "success": false,
  "message": "Produk tidak sesuai dengan game yang dipilih."
}
Validasi payload gagal
422
{
  "message": "The id field is required. (and 2 more errors)",
  "errors": {
    "id": [
      "The id field is required."
    ],
    "game": [
      "The game field is required."
    ],
    "whatsapp": [
      "The whatsapp field is required."
    ]
  }
}