Tài liệu API
API base: https://api.gdtguytin.xyz/api/v1/index.php
🔐 Xác thực
Mọi request cần Bearer token. Tạo trong admin/api-keys.php.
Authorization: Bearer slk_live_<40 ký tự hex>
🔗 Liên kết ngân hàng
- Vào
/admin/link-bank.php - Nhập STK + username IB + mật khẩu
- Nhập OTP
- Hệ thống lưu session đã mã hóa
GET /banks
curl -H "Authorization: Bearer slk_live_..." \
"https://api.gdtguytin.xyz/api/v1/index.php?path=banks"
{ "object": "list", "data": [{ "id":1, "bank_code":"MBB", "bank_name":"MB Bank", "account_number":"0123", "status":"linked" }] }
GET /transactions
| Param | Kiểu | Mô tả |
|---|---|---|
| bank_id | int | Bắt buộc |
| from | date | YYYY-MM-DD |
| to | date | YYYY-MM-DD |
| limit | int | max 500 |
curl -H "Authorization: Bearer slk_live_..." \
"https://api.gdtguytin.xyz/api/v1/index.php?path=transactions&bank_id=1"
GET /balance
curl -H "Authorization: Bearer slk_live_..." \
"https://api.gdtguytin.xyz/api/v1/index.php?path=balance&bank_id=1"
POST /webhooks
curl -X POST -H "Authorization: Bearer slk_live_..." \
-H "Content-Type: application/json" \
-d '{"url":"https://your-app.com/hooks"}' \
"https://api.gdtguytin.xyz/api/v1/index.php?path=webhooks"
🛡️ Verify HMAC
<?php
$raw=file_get_contents('php://input');
$ts=$_SERVER['HTTP_X_WEBHOOK_TIMESTAMP']??'';
$sig=$_SERVER['HTTP_X_WEBHOOK_SIGNATURE']??'';
$secret='whsec_...';
$exp='sha256='.hash_hmac('sha256',$ts.'.'.$raw,$secret);
if(!hash_equals($exp,$sig)){http_response_code(401);exit;}
if(abs(time()-(int)$ts)>300){http_response_code(401);exit;}
$data=json_decode($raw,true);
http_response_code(200);echo '{"ok":true}';
⚠️ Mã lỗi
| HTTP | Error | Ý nghĩa |
|---|---|---|
| 401 | unauthorized | Sai Bearer token |
| 404 | bank_not_found | bank_id không thuộc bạn |
| 502 | upstream | Ngân hàng lỗi |