Push Payment to Devices
POST /openapi/v1/devices/payments/push
Đẩy thông tin thanh toán (số tiền + mã QR) trực tiếp xuống thiết bị vật lý tại quầy thu ngân.
Payload POS (Smart POS):
{
"serial_no": "00059012710",
"order_id": "0129210912",
"amount": 150000,
"type": "pos"
}
Payload Soundbox:
{
"serial_no": "SB-001234",
"amount": 150000,
"qr_string": "00020101021138550010A000000727...",
"type": "soundbox"
}
| Trường | Bắt buộc | Mô tả |
|---|---|---|
serial_no | ✅ | Số serial của thiết bị |
order_id | ✅ nếu type == "pos" | Mã hóa đơn |
amount | ✅ | Số tiền (VNĐ) |
qr_string | ✅ nếu type == "soundbox" | Chuỗi QR từ API Create QR |
type | ✅ | "pos" hoặc "soundbox" |
- cURL
- Python
- Go
- JavaScript
curl --location '<base_url>/openapi/v1/devices/payments/push' \
--header 'Partner-Code: YOUR_PARTNER_CODE' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsI…' \
--data '{
"data": ENCRYPTED_PAYLOAD
}'
import requests
url = "<base_url>/openapi/v1/devices/payments/push"
payload = {"data": "ENCRYPTED_PAYLOAD"}
headers = {
"Partner-Code": "YOUR_PARTNER_CODE",
"Content-Type": "application/json",
"Authorization": "Bearer eyJhbGciOiJSUzI1NiIsI…",
}
response = requests.post(url, headers=headers, json=payload)
print(response.text)
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
url := "<base_url>/openapi/v1/devices/payments/push"
body := strings.NewReader(`{"data":"ENCRYPTED_PAYLOAD"}`)
req, _ := http.NewRequest("POST", url, body)
req.Header.Set("Partner-Code", "YOUR_PARTNER_CODE")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer eyJhbGciOiJSUzI1NiIsI…")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
result, _ := io.ReadAll(resp.Body)
fmt.Println(string(result))
}
const response = await fetch("<base_url>/openapi/v1/devices/payments/push", {
method: "POST",
headers: {
"Partner-Code": "YOUR_PARTNER_CODE",
"Content-Type": "application/json",
"Authorization": "Bearer eyJhbGciOiJSUzI1NiIsI…",
},
body: JSON.stringify({ data: "ENCRYPTED_PAYLOAD" }),
});
const result = await response.text();
console.log(result);
Request
Headers
| Name | Required | Description |
|---|---|---|
Partner-Code | ✅ | Mã định danh Merchant (TCONNECT cung cấp) |
Content-Type | ✅ | application/json |
Authorization | ✅ | Bearer <access_token> |
Body
| Field | Type | Required | Description |
|---|---|---|---|
data | string | ✅ | Payload đã mã hóa AES-256-CBC dạng Hexadecimal |
Response
200 — Gửi lệnh xuống thiết bị thành công
| Field | Type | Description |
|---|---|---|
message | string | Xác nhận trạng thái gửi lệnh (ví dụ: "Successfully pushed new payment to Soundbox") |