Dokumentasi API
API transaksi H2H (Host to Host) untuk integrasi otomatis ke Lvyy Store
https://elvyy.id/api
Authorization: Bearer YOUR_API_KEY
Semua endpoint API memerlukan API key yang valid. Kirimkan melalui header HTTP:
Authorization: Bearer your_api_key_here
API key dapat dibuat sendiri melalui halaman Dashboard → API Key setelah login.
Request Signing (wajib untuk POST)
Setiap request POST (transaksi) wajib menyertakan ref_id dan sign di body JSON:
sign = HMAC-SHA256(username + apikey, ref_id)
// username = kolom username akun Anda (bukan email)
// apikey = API key Anda
// ref_id = kode referensi unik dari sisi Anda (sebagai key HMAC)
// Contoh PHP:
$sign = hash_hmac('sha256', "facatar99" . "your_api_key", "INV001");
IP Whitelist (opsional)
Anda dapat membatasi akses API hanya dari IP tertentu melalui halaman Dashboard → API Key. Jika whitelist kosong, semua IP diizinkan.
Penting: Jaga kerahasiaan API key Anda. Jangan menaruh API key di sisi client (frontend/mobile app). Gunakan selalu di sisi server.
/api/saldo
AUTH REQUIRED
Mengambil informasi saldo akun Anda.
Response
{
"success": true,
"message": "Informasi saldo berhasil diambil.",
"data": {
"user_id": 1,
"email": "reseller@example.com",
"nama": "Nama Reseller",
"level": "reseller",
"balance": 500000
}
}
/api/pricelist
AUTH REQUIRED
Mengambil daftar harga semua produk yang tersedia.
Query Parameters
| Parameter | Tipe | Status | Keterangan |
|---|---|---|---|
category |
string | optional | Slug atau nama kategori: game, pulsa, voucher, e-wallet, premium |
operator |
string | optional | Slug atau nama operator (mobile-legends, Mobile Legends) |
search |
string | optional | Cari berdasarkan nama produk |
Contoh Request
GET https://elvyy.id/api/pricelist?category=game&operator=mobile-legends
Response
{
"success": true,
"message": "Daftar harga berhasil diambil.",
"data": {
"total": 25,
"products": [
{
"product_sku": "MLWDP",
"product_name": "Mobile Legends 86 Diamonds",
"price": 20000,
"status": "available",
"operator_name": "Mobile Legends",
"operator_slug": "mobile-legends",
"category_name": "Game",
"category_slug": "game"
}
]
}
}
/api/transaction
AUTH REQUIRED
Membuat transaksi pembelian produk. Saldo akan langsung dipotong.
Request Body (JSON)
| Field | Tipe | Status | Keterangan |
|---|---|---|---|
product_sku |
string | required | SKU produk dari pricelist (field product_sku) |
target |
string | required | Nomor HP / User ID game |
ref_id |
string | required | Kode referensi unik dari sisi Anda (untuk signing & idempotency) |
sign |
string | required | HMAC-SHA256(username + apikey, ref_id) — username = kolom username akun |
server |
string | conditional | Zone ID / Server. Wajib untuk game seperti Mobile Legends |
Contoh Request
POST https://elvyy.id/api/transaction
Content-Type: application/json
Authorization: Bearer your_api_key
{
"product_sku": "MLWDP",
"target": "12345678",
"ref_id": "INV001",
"sign": "a1b2c3d4e5f6...",
"server": "1234"
}
// sign = hash_hmac('sha256', "facatar99" . "your_api_key", "INV001")
Response Sukses (201)
{
"success": true,
"message": "Transaksi berhasil dibuat.",
"data": {
"transaction_code": "TRX20250905103000ABCDEF",
"invoice_code": "INV2025090000000001XYZABC",
"product_name": "Mobile Legends 86 Diamonds",
"target": "12345678",
"price": 20000,
"status": "processing",
"remaining_balance": 480000,
"created_at": "2025-09-05 10:30:00"
}
}
Response Error (400)
{
"success": false,
"message": "Saldo tidak mencukupi. Saldo: Rp 10.000, Harga: Rp 20.000"
}
Catatan: Status awal adalah processing. Gunakan endpoint Cek Status untuk memantau hingga success atau failed.
/api/status?transaction_code=TRX...
AUTH REQUIRED
Mengecek status transaksi berdasarkan kode transaksi atau kode invoice.
Query Parameter
| Parameter | Tipe | Status | Keterangan |
|---|---|---|---|
transaction_code |
string | required | Kode transaksi (TRX...) atau kode invoice (INV...) |
Contoh Request
GET https://elvyy.id/api/status?transaction_code=TRX202608100059355E9UDH
Response
{
"success": true,
"message": "Status transaksi berhasil diambil.",
"data": {
"transaction_code": "TRX202608100059355E9UDH",
"invoice_code": "INV2025090000000001XYZABC",
"product_name": "Mobile Legends 86 Diamonds",
"operator_name": "Mobile Legends",
"category_name": "Game",
"target": "12345678",
"server": "1234",
"price": 20000,
"status": "success",
"sn": "MG17XXXXXXXXXX",
"created_at": "2025-09-05 10:30:00",
"updated_at": "2025-09-05 10:30:15"
}
}
Status Transaksi
| Status | Keterangan |
|---|---|
pending |
Menunggu pembayaran (tidak berlaku untuk API) |
processing |
Sedang diproses oleh provider |
success |
Berhasil. Field sn = serial number |
failed |
Gagal. Saldo dikembalikan otomatis. |
expired |
Transaksi kadaluarsa |
{callback_url_anda}
DIKIRIM OTOMATIS
Jika Anda mendaftarkan callback_url pada API key, Lvyy Store akan mengirim POST ke URL tersebut setiap kali status transaksi berubah.
Cara mendaftar: Atur callback URL melalui halaman Dashboard → API Key setelah login.
Format Callback yang Diterima
{
"transaction_code": "TRX20250905103000ABCDEF",
"invoice_code": "INV2025090000000001XYZABC",
"product_name": "Mobile Legends 86 Diamonds",
"target": "12345678",
"price": 20000,
"status": "success",
"sn": "MG17XXXXXXXXXX",
"message": "Transaksi Sukses",
"timestamp": "2025-09-05 10:30:15"
}
Yang Perlu Dilakukan Server Anda
- Terima POST request dengan body JSON
- Proses data sesuai kebutuhan bisnis Anda
- Kembalikan response HTTP 200
Penting: Callback dapat dikirim lebih dari sekali. Pastikan server Anda bersifat idempotent -- cek apakah transaksi sudah pernah diproses.
SDK PHP resmi untuk integrasi cepat dengan API Lvyy Store. Cukup install via Composer dan gunakan.
Instalasi
composer require lvyy/sdk-php
Atau download manual file LvyyApi.php di bawah dan include ke project Anda.
File SDK: LvyyApi.php
<?php
/**
* Lvyy Store PHP SDK
*
* Usage:
* $api = new LvyyApi('facatar99', 'YOUR_API_KEY');
* $saldo = $api->saldo();
* $prices = $api->pricelist(['category' => 'games']);
* $trx = $api->transaction([
* 'product_sku' => 'MLWDP',
* 'target' => '081234',
* 'ref_id' => 'INV001',
* ]);
* $status = $api->status('INV001');
*/
class LvyyApi
{
private string $username;
private string $apiKey;
private string $baseUrl;
private int $timeout;
public function __construct(string $username, string $apiKey, string $baseUrl = 'https://lvyy.host/api', int $timeout = 30)
{
$this->username = $username; // kolom username dari akun Anda
$this->apiKey = $apiKey;
$this->baseUrl = rtrim($baseUrl, '/');
$this->timeout = $timeout;
}
/** Cek saldo akun */
public function saldo(): array
{
return $this->request('GET', '/saldo');
}
/** Daftar harga produk */
public function pricelist(array $params = []): array
{
$query = !empty($params) ? '?' . http_build_query($params) : '';
return $this->request('GET', '/pricelist' . $query);
}
/** Buat transaksi pembelian (otomatis generate sign) */
public function transaction(array $data): array
{
if (empty($data['ref_id'])) {
throw new InvalidArgumentException('ref_id is required for transaction');
}
// Auto-generate signature
$data['sign'] = hash_hmac('sha256', $this->username . $this->apiKey, $data['ref_id']);
return $this->request('POST', '/transaction', $data);
}
/** Cek status transaksi */
public function status(string $transactionCode): array
{
return $this->request('GET', '/status/' . urlencode($transactionCode));
}
/** Internal: kirim HTTP request */
private function request(string $method, string $endpoint, ?array $body = null): array
{
$url = $this->baseUrl . $endpoint;
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => $this->timeout,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Bearer ' . $this->apiKey,
'Accept: application/json',
],
]);
if ($method === 'POST' && $body !== null) {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
}
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
if ($error) {
throw new RuntimeException("LvyyApi cURL error: {$error}");
}
$result = json_decode($response, true);
if ($result === null) {
throw new RuntimeException("LvyyApi invalid JSON response (HTTP {$httpCode})");
}
if ($httpCode >= 400) {
throw new RuntimeException(
"LvyyApi error (HTTP {$httpCode}): " . ($result['message'] ?? 'Unknown error'),
$httpCode
);
}
return $result;
}
}
Contoh Penggunaan
require_once 'LvyyApi.php';
$api = new LvyyApi('facatar99', 'YOUR_API_KEY');
// 1. Cek Saldo
$saldo = $api->saldo();
echo "Saldo: Rp " . number_format($saldo['data']['balance']);
// 2. Ambil Daftar Harga
$prices = $api->pricelist(['category' => 'games']);
foreach ($prices['data']['products'] as $product) {
echo $product['product_name'] . " - Rp " . number_format($product['price']) . "\n";
}
// 3. Buat Transaksi (sign di-generate otomatis oleh SDK)
try {
$trx = $api->transaction([
'product_sku' => 'MLWDP',
'target' => '12345678',
'ref_id' => 'INV001',
'server' => '1234',
]);
echo "Transaksi: " . $trx['data']['transaction_code'];
echo "Status: " . $trx['data']['status'];
} catch (RuntimeException $e) {
echo "Error: " . $e->getMessage();
}
// 4. Cek Status (gunakan ref_id yang sama)
$status = $api->status('INV001');
echo "Status: " . $status['data']['status'];
if ($status['data']['status'] === 'success') {
echo "SN: " . $status['data']['sn'];
}
Contoh Callback Handler
// callback.php - URL yang didaftarkan sebagai callback_url
<?php
$input = json_decode(file_get_contents('php://input'), true);
if (!$input || empty($input['transaction_code'])) {
http_response_code(400);
exit;
}
$trxCode = $input['transaction_code'];
$status = $input['status'];
$sn = $input['sn'] ?? null;
// Idempotent check - pastikan belum pernah diproses
$db = new PDO('mysql:host=localhost;dbname=mydb', 'user', 'pass');
$stmt = $db->prepare("SELECT processed FROM callbacks WHERE trx_code = ?");
$stmt->execute([$trxCode]);
$row = $stmt->fetch();
if ($row && $row['processed']) {
http_response_code(200); // Sudah diproses, abaikan
exit;
}
// Proses callback
if ($status === 'success') {
// Berikan produk ke customer
deliverProduct($trxCode, $sn);
} elseif ($status === 'failed') {
// Refund ke customer
refundCustomer($trxCode);
}
// Tandai sudah diproses
$stmt = $db->prepare("INSERT INTO callbacks (trx_code, status, sn, processed) VALUES (?, ?, ?, 1) ON DUPLICATE KEY UPDATE processed = 1");
$stmt->execute([$trxCode, $status, $sn]);
http_response_code(200);
Semua error dikembalikan dalam format JSON konsisten:
{
"success": false,
"message": "Deskripsi error",
"errors": {}
}
Kode HTTP Status
| Kode | Keterangan |
|---|---|
200 | Berhasil |
201 | Transaksi berhasil dibuat |
400 | Bad Request - Parameter tidak valid / saldo kurang |
401 | Unauthorized - API key tidak valid |
403 | Forbidden - Tidak memiliki akses |
404 | Not Found |
422 | Validasi gagal |
500 | Internal Server Error |