Tài Liệu Tích Hợp API & SDK Dành Cho Developer
Hướng dẫn kết nối hệ thống tự động qua RESTful API tiêu chuẩn (JSON response, chữ ký HMAC-SHA256).
POST
https://api.dichvudark.vip/v1/orders/create
Endpoint tạo đơn hàng và sinh mã VietQR động để khách quét thanh toán.
Code Mẫu PHP cURL:
<?php
$payload = [
'partner_id' => 'PARTNER_D41D8CD98F',
'order_code' => 'ORD_' . time(),
'amount' => 100000,
'description'=> 'Thanh toan don hang #1234',
'return_url' => 'https://yourweb.com/success',
];
$payload['signature'] = hash_hmac('sha256', json_encode($payload), 'YOUR_SECRET_KEY');
$ch = curl_init('https://api.dichvudark.vip/v1/orders/create');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
echo "QR Code URL: " . $result['data']['qr_url'];
?>
JSON Response Trả Về:
{
"status": "success",
"code": 200,
"message": "Khoi tao don hang thanh cong",
"data": {
"order_code": "ORD_1729000000",
"amount": 100000,
"qr_url": "https://img.vietqr.io/image/MB-0399888999-compact2.png?amount=100000&addInfo=ORD_1729000000",
"expires_in": 900
}
}