Transaction API#
API giao dịch: xem số dư, tạo giao dịch, lịch sử giao dịch.
Base URL: https://app.socialking.vn/api/v1
1. Xem số dư hiện tại#
GET /transaction/get-current-balance
#
Auth: Bearer Token (JWT)
Response (200):
{
"success": true,
"data": {
"currentBalance": "1500000",
"currentBalanceNumber": 1500000,
"formattedBalance": "1.500.000 VND"
}
}2. Tạo giao dịch#
POST /transaction/create
#
Auth: Bearer Token (JWT)
Request Body:
{
"type": "credit",
"amount": 500000,
"note": "Nạp tiền qua VietQR"
}| Field | Type | Required | Validation |
|---|---|---|---|
email | string | No | Email user (cho manager) |
type | string | Yes | credit | debit |
amount | number | Yes | > 0, integer, max 500.000.000 |
note | string | No | Max 255 ký tự, nullable |
transaction_data | any | No | Dữ liệu bổ sung, nullable |
status | string | No | pending | completed | failed, default completed |
Response (201):
{
"success": true,
"data": {
"id": "uuid-string",
"type": "credit",
"amount": 500000,
"status": "completed",
"post_balance": 2000000,
"createdAt": "2026-03-30T10:30:00Z"
}
}3. Lịch sử giao dịch#
GET /transaction/get-history
#
Auth: Bearer Token (JWT)
Query Parameters:
| Param | Type | Default | Mô tả |
|---|---|---|---|
_page | number | 1 | Trang |
_limit | number | 20 | Items/trang |
_order | string | desc | asc | desc |
type | string | - | credit | debit |
status | string | - | Filter theo status |
Response (200):
{
"success": true,
"data": {
"transactions": [
{
"id": "uuid-string",
"type": "credit",
"amount": 500000,
"status": "completed",
"post_balance": 2000000,
"note": "Nạp tiền qua VietQR",
"createdAt": "2026-03-30T10:30:00Z"
}
],
"total": 42,
"balance": 2000000
}
}4. Tất cả giao dịch (Manager)#
GET /transaction/get-all
#
Auth: Bearer Token (JWT) + Permission manager_transaction:read
Rate Limit: 30 req/sec
Query Parameters:
| Param | Type | Default | Mô tả |
|---|---|---|---|
_page | number | 1 | Trang |
_limit | number | 20 | Items/trang |
_order | string | desc | asc | desc |
_search | string | - | Tìm kiếm |
type | string | - | credit | debit |
status | string | - | Filter theo status |
userId | UUID | - | Filter theo user |
5. Dashboard Stats (Manager)#
GET /transaction/dashboard-stats
#
Auth: Bearer Token (JWT) + Permission
Rate Limit: 10 req/sec
Response (200):
{
"success": true,
"data": {
"totalCredit": 50000000,
"totalDebit": 30000000,
"netBalance": 20000000,
"transactionCount": 150,
"averageTransaction": 333333
}
}6. Hoàn giao dịch (Manager)#
POST /transaction/reverse/:transactionId
#
Auth: Bearer Token (JWT) + Permission manager_transaction:reverse
Rate Limit: 5 req/sec
URL Params: transactionId (UUID)
Request Body:
{
"reason": "Hoàn tiền theo yêu cầu"
}