# Docs API wallets
## Môi trường:
### Host
| Môi trường | Host |
| :--- | :--- |
| testing | https://buyer.1short.click |
| production | https://buyer.1short.io |
## Sequence
```mermaid
sequenceDiagram
User->>+Buyer.1Short: Lấy thông tin và chuyển khoản
Buyer.1Short-->>-Api.Web2m: Call api lịch sử nạp
Api.Web2m->>+Buyer.1Short: Trả về lịch sử nạp?
Buyer.1Short-->>-User: Xử lý giao dịch và cộng tiền!
```
## Flow
```mermaid
graph TD
A[User] -->|Nạp tiền theo cú pháp| B(Buyer.1Short)
B -->|Queue Job api|C{Lấy danh sách api}
C -->|Queue Job api 1| D[Web2m]
C -->|Queue Job api 2| E[Web2m]
C -->|Queue Job api n+...| F[Web2m]
D -->|Job| G(Xử lý giao dịch)
E -->|Job| G(Xử lý giao dịch)
F -->|Job| G(Xử lý giao dịch)
G --> |Cộng tiền User| HIGHLIGHT[User]
```
### 1. Màn danh sách Api tích hợp thêm tài khoản
#### 1.1 API thêm tài khoản
| Title | Type |
|:----------|:--------|
| `Endpoint` | `https:{{domain}}/api/admin/wallets` |
| `Description` | `Api thêm tài khoản tích hợp`|
| `Method` | `POST` |
| `X-XSRF-TOKEN` | `token` |
#### Request Params
| Parameter | Type | Description |
|:----------|:--------|:---------------------|
| `wallet_code` | `string` | mã ví (MOMO, VCB) |
| `wallet_number` | `string` | số tài khoản ví |
| `wallet_holder` | `string` | Chủ sở hữu tài khoàn |
| `api_token` | `string` | token api |
| `api_username` | `string` | username api |
| `api_password` | `string` | password api |
| `schedule_time` | `int` | thời gian chạy job |
| `type` | `int` | Loại ví - 0: digital wallet, 1: bank wallet |
| `status` | `int` | Trạng thái api - 0: không kích hoạt, 1: kích hoạt |
| `notify` | `string` | Thông báo của api |
#### Sample Request
```curl
curl --location --request POST '{{domain}}/api/admin/wallets?wallet_code=VCB&wallet_number=010993236&wallet_holder=NGUYEN DUC ANH&api_token=abc188asd8nasdh&schedule_time=5&type=1&status=1¬ify=chúc mừng bạn đã đăng kí thành công&api_username=anhnd116&api_password=hayhascoddi' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Cookie: xxx_xxx' \
--header 'Pragma: no-cache' \
--header 'Sec-Fetch-Dest: empty' \
--header 'Sec-Fetch-Mode: cors' \
--header 'X-Locale: vi' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'X-XSRF-TOKEN: xxx_xxx'
```
#### Sample Response
```json
{
"success": true,
"data":
}
```
#### 1.2 API update tài khoản
| Title | Type|
|:----------|:--------|
| `Endpoint` | `https:{{domain}}/api/admin/wallets/{id}` |
| `Description` | `Api update tài khoản tích hợp` |
| `Method` | `POST` |
| `X-XSRF-TOKEN` | `token` |
| Parameter | Type | Description |
|:----------|:--------|:---------------------|
| `wallet_code` | `string` | mã ví (MOMO, VCB) |
| `wallet_number` | `string` | số tài khoản ví |
| `wallet_holder` | `string` | Chủ sở hữu tài khoàn |
| `api_token` | `string` | token api |
| `api_username` | `string` | username api |
| `api_password` | `string` | password api |
| `schedule_time` | `int` | thời gian chạy job |
| `type` | `int` | Loại ví - 0: digital wallet, 1: bank wallet |
| `status` | `int` | Trạng thái api - 0: không kích hoạt, 1: kích hoạt |
| `notify` | `string` | Thông báo của api |
#### Sample Request
```curl
curl --location --request POST '{{domain}}/api/admin/wallets/1?wallet_code=MOMO&wallet_number=0905188662&wallet_holder=NGUYEN DUC ANH&api_token=asdasd12212das&schedule_time=5&type=0&status=0¬ify=test thoi ma' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundarycY86XByyWFZAJZVv' \
--header 'Cookie: xxx_xxx' \
--header 'X-XSRF-TOKEN: xxx_xxx'
```
#### Sample Response
```json
{
"success": true,
"data":
}
```
#### 1.3 API dánh sách tài khoản
| Title | Type |
|:----------|:--------|
| `Endpoint` | `https:{{domain}}/api/admin/wallets` |
| `Description` | `Api danh sách tài khoản tích hợp` |
| `Method` | `GET` |
| `X-XSRF-TOKEN` | `token` |
| Parameter | Type | Description |
|:----------|:--------|:---------------------|
| `status` | `int` | Trạng thái hoạt động của ví (0: không kích hoạt, 1: kích hoạt) |
#### Sample Request
```curl
curl --location --request GET '{{domain}}/api/admin/wallets?status=0' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Accept-Language: vi,vi-VN;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5,hy;q=0.4' \
--header 'Cache-Control: no-cache' \
--header 'Connection: keep-alive' \
--header 'Cookie: xxx_xxx' \
--header 'X-Locale: vi' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'X-XSRF-TOKEN: xxx_xxx' \
```
#### Sample Response
```json
{
"data": [
{
"id": 1,
"wallet_code": "MOMO",
"wallet_number": "0905188662",
"wallet_holder": "NGUYEN DUC ANH",
"api_token": "asdasd12212das",
"api_username": null,
"api_password": null,
"schedule_time": 5,
"type": 0,
"status": 0,
"notify": "test thoi ma"
}
]
}
```
### 2. Màn hình setting tỉ lệ khuyến mãi, cài đặt thông báo
#### 2.1 API thêm tỉ lệ khuyến mãi, cài đặt thông báo
| Title | Type |
|:----------|:--------|
| `Endpoint` | `https:{{domain}}/api/admin/settings/wallets` |
| `Description` | `Api thêm tỉ lệ khuyến mãi thông báo nạp tiền` |
| `Method` | `POST` |
| `X-XSRF-TOKEN` | `token` |
| Parameter | Type | Description |
|:----------|:--------|:---------------------|
| `wallet_discount_bank` | `int` | Tỉ lệ khuyến mãi khi nạp tiền |
| `wallet_notify_bank_charge` | `string` | Thông báo nạp tiền |
#### Sample Request
```curl
curl --location --request POST 'https://buyer.1short.local/api/admin/settings/wallets?wallet_discount_bank=20&wallet_notify_bank_charge=nap tien1.short ' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Accept-Language: vi,vi-VN;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5,hy;q=0.4' \
--header 'Cache-Control: no-cache' \
--header 'Connection: keep-alive' \
--header 'Cookie: xxx_xxx' \
--header 'DNT: 1' \
--header 'X-Locale: vi' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'X-XSRF-TOKEN: xxx_xxx' \
```
#### Sample Response
#### 2.2 API lấy tỉ lệ khuyến mãi, cài đặt thông báo
| Title | Type |
|:----------|:-------- |
| `Endpoint` | `https:{{domain}}/api/admin/settings/wallets` |
| `Description` | `Api lấy tỉ lệ khuyến mãi thông báo nạp tiền` |
| `Method` | `GET` |
| `X-XSRF-TOKEN` | `token` |
#### Sample Request
```curl
curl --location --request GET 'https://buyer.1short.local/api/admin/settings/wallets' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Accept-Language: vi,vi-VN;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5,hy;q=0.4' \
--header 'Cache-Control: no-cache' \
--header 'Connection: keep-alive' \
--header 'Cookie: xxx_xxx' \
--header 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' \
--header 'X-Locale: vi' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'X-XSRF-TOKEN: xxx_xxx' \
```
#### Sample Response
```json
{
"data": {
"wallet_discount_bank": 20,
"wallet_notify_bank_charge": "nap tien1.short"
}
}
```
### 3 Màn lịch sử nạp tiền
#### 3.1 API màn danh sách lịch sử nạp tiền
| Title | Type |
|:----------|:-------- |
| `Endpoint` | `https:{{domain}}/api/admin/wallets-transaction` |
| `Description` | `Api danh sách màn hình lịch sử nạp tiền ` |
| `Method` | `GET` |
| `X-XSRF-TOKEN` | `token` |
#### Sample Request
```
curl --location --request GET 'https://buyer.1short.local/api/admin/wallets-transaction' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Accept-Language: vi,vi-VN;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5,hy;q=0.4' \
--header 'Cookie: xxx_xxx' \
--header 'DNT: 1' \
--header 'Pragma: no-cache' \
--header 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' \
--header 'X-Locale: vi' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'X-XSRF-TOKEN: xxx_xxx'
```
#### Params
| Parameter | Type | Description |
|:----------|:--------|:---------------------|
| `status` | `int` | Trạng thái giao dịch 0 thất bại, 1 thành công |
| `user_id` | `int` | id của users nạp tiền |
| `transaction_id` | `string` | id của transaction |
| `from` | `datetime` | Thời gian giao dịch |
| `to` | `datetime` | Thời gian giao dịch |
| `amount` | `int` | Khoảng tiền giao dịch |
| `schedule_time` | `int` | thời gian chạy job |
| `recharge_api_id` | `int` | Loại ví - 0: digital wallet, 1: bank wallet |
|
#### Same response
```
{
"data": [
{
"id": 1,
"user_id": 3,
"transaction_id": "123456789",
"recharge_api_id": 1,
"amount": "30000.00",
"actual_amount": "40000.00",
"status": 1,
"message": "admin 1.short nap tien ",
"user": {
"name": "Nguyễn Đức Thành",
"id": 3,
"email": "lonelyvagabon@hotmail.com"
},
"created_at": "2022-12-21T16:04:31.000000Z"
},
{
"id": 2,
"user_id": 1,
"transaction_id": "889248294020",
"recharge_api_id": 2,
"amount": "50000.00",
"actual_amount": "60000.00",
"status": 1,
"message": "admin 1.short nap tien",
"user": {
"name": "Admin",
"id": 1,
"email": "system@example.com"
},
"created_at": "2022-12-10T16:04:31.000000Z"
}
],
"total": "80000.00"
}
```
#### 3.2 API chi tiết thông tin theo transaction
| Title | Type |
|:----------|:-------- |
| `Endpoint` | `https:{{domain}}/api/admin/wallets-transaction/detail` |
| `Description` | `API chi tiết thông tin theo transaction ` |
| `Method` | `GET` |
| `X-XSRF-TOKEN` | `token` |
#### Sample Request
```
curl --location --request GET 'https://buyer.1short.local/api/admin/wallets-transaction/detail?transaction_id=889248294020' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Accept-Language: vi,vi-VN;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5,hy;q=0.4' \
--header 'Cookie: xxx_xxx' \
--header 'X-Locale: vi' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'X-XSRF-TOKEN: xxx_xxx'
```
#### Params
| Parameter | Type | Description |
|:----------|:--------|:---------------------|
| `transaction_id` | `string` | id của giao dịch |
#### Same response
```
{
"data": [
{
"id": 2,
"user_id": 1,
"transaction_id": "889248294020",
"recharge_api_id": 2,
"amount": "50000.00",
"actual_amount": "60000.00",
"status": 1,
"message": "admin 1.short nap tien",
"user": {
"name": "Admin",
"id": 1,
"email": "system@example.com"
},
"created_at": "2022-12-10T16:04:31.000000Z"
}
]
}
```
#### 3.3 API cộng/trừ giao dịch theo transaction
| Title | Type |
|:----------|:-------- |
| `Endpoint` | `https:{{domain}}/api/admin/wallets-transaction/{id}` |
| `Description` | `API cộng/trừ giao dịch theo transaction` |
| `Method` | `POST` |
| `X-XSRF-TOKEN` | `token` |
#### Sample Request
```
curl --location --request POST '{{domain}}/api/admin/wallets-transaction/2?amount=10000&status=1' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Accept-Language: vi,vi-VN;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5,hy;q=0.4' \
--header 'Cache-Control: no-cache' \
--header 'Connection: keep-alive' \
--header 'Cookie: xxx_xxx' \
--header 'X-XSRF-TOKEN: xxx_xxx' \
```
#### Params
| Parameter | Type | Description |
|:----------|:--------|:---------------------|
| `amount` | `int` | số tiền +/- |
| `status` | `int` | 0: trừ tiền 1: cộng tiền |
| `user_id` | `int` | id của user |
#### Same response
```
{
"data": {
"id": 2,
"user_id": 1,
"transaction_id": "889248294020",
"recharge_api_id": 2,
"amount": 10000,
"actual_amount": 12000,
"status": 1,
"message": "admin 1.short nap tien",
"created_at": "2022-12-10T16:04:31.000000Z",
"updated_at": "2022-12-22T09:15:30.000000Z"
}
}
```
#### 4.1 API client show thông tin tài khoản
| Title | Type |
|:----------|:-------- |
| `Endpoint` | `https:{{domain}}/api/client/wallets?wallet_code=MOMO` |
| `Description` | `API client show thông tin tài khoản` |
| `Method` | `GET` |
| `X-XSRF-TOKEN` | `token` |
#### Sample Request
```
curl --location --request GET 'https://buyer.1short.local/api/client/wallets?wallet_code=MOMO' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Accept-Language: vi,vi-VN;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5,hy;q=0.4' \
--header 'Cache-Control: no-cache' \
--header 'Connection: keep-alive' \
--header 'Cookie: xxx_xx' \
--header 'X-Locale: vi' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'X-XSRF-TOKEN: xxx_xxx
```
#### Params
| Parameter | Type | Description |
|:----------|:--------|:---------------------|
| `wallet_code` | `string` | code |
#### Same response
```
{
"data": [
{
"wallet_code": "MOMO",
"wallet_number": "0905188662",
"wallet_holder": "NGUYEN DUC ANH",
"type": 0,
"notify": "test thoi ma"
}
]
}
```
#### 4.2 API lấy biến động số dư của buyer
| Title | Type |
|:----------|:-------- |
| `Endpoint` | `https:{{domain}}/api/client/transaction-history` |
| `Description` | `API lấy biến động số dư của buyer` |
| `Method` | `GET` |
| `X-XSRF-TOKEN` | `token` |
#### Sample Request
```
curl --location --request GET '{{domain}}/api/client/transaction-history' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Accept-Language: vi,vi-VN;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5,hy;q=0.4' \
--header 'Cache-Control: no-cache' \
--header 'Connection: keep-alive' \
--header 'Cookie: xxx_xxx' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'X-XSRF-TOKEN: xxx_xxx
```
| Parameter | Type | Description |
|:----------|:--------|:---------------------|
| `from` | `datetime` | Thời gian giao dịch |
| `to` | `datetime` | Thời gian giao dịch |
| `amount` | `int` | Khoảng tiền giao dịch |
#### Same response
```
{
"data": [
{
"handle_id": 1,
"handle_model": 1,
"user_id": 1,
"amount": "10000.00",
"actual_amount": "12000.00",
"type": 1,
"reason": 4,
"note": "Admin thực hiện giao dịch"
}
],
"total": "10000.00"
}
```
#### 4.3 API màn lịch sử nạp tiền (buyer)
| Title | Type |
|:----------|:-------- |
| `Endpoint` | `https:{{domain}}/api/client/wallets-transaction` |
| `Description` | `API màn lịch sử nạp tiền` |
| `Method` | `GET` |
| `X-XSRF-TOKEN` | `token` |
#### Sample Request
```
curl --location --request GET '{{domain}}/api/client/wallets-transaction' \
--header 'Cookie: xxx_xxx' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'X-XSRF-TOKEN: xxx_xx
```
| Parameter | Type | Description |
|:----------|:--------|:---------------------|
| `from` | `datetime` | Thời gian giao dịch |
| `to` | `datetime` | Thời gian giao dịch |
| `amount` | `int` | Khoảng tiền giao dịch |
#### Same response
```
{
"data": [
{
"id": 2,
"user_id": 1,
"transaction_id": "889248294020",
"recharge_api_id": 2,
"amount": "10000.00",
"actual_amount": "12000.00",
"status": 1,
"message": "admin 1.short nap tien",
"user": {
"name": "Admin",
"id": 1,
"email": "system@example.com"
},
"created_at": "2022-12-10T16:04:31.000000Z"
}
],
"total": "10000.00"
}
```