Create QR
POST /openapi/v1/qr
Tạo mã QR thanh toán cho một đơn hàng.
Gọi Get Services trước để lấy service_code (dùng làm header x-service-code) và bincode.
Payload trước khi mã hóa:
{
"order_id": "f3a9c8a1-7bc2-4b9d-9df2-2fc6fbb91234",
"va": "VA100023312",
"bincode": "970454",
"amount": 10000
}
| Trường | Bắt buộc | Mô tả |
|---|---|---|
order_id | ✅ | Mã hóa đơn |
va | ✅ | Số tài khoản ảo |
bincode | ✅ | Mã ngân hàng |
amount | ❌ | 0 hoặc bỏ trống = QR tĩnh; > 0 = QR động |
- cURL
- Python
- Go
- JavaScript
curl --location '<base_url>/openapi/v1/qr' \
--header 'partner-code: YOUR_PARTNER_CODE' \
--header 'x-service-code: vccb-qr' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI…' \
--header 'Content-Type: application/json' \
--data '{
"data": ENCRYPTED_PAYLOAD
}'
import requests
url = "<base_url>/openapi/v1/qr"
payload = {"data": "ENCRYPTED_PAYLOAD"}
headers = {
"partner-code": "YOUR_PARTNER_CODE",
"x-service-code": "vccb-qr",
"Authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI…",
"Content-Type": "application/json",
}
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/qr"
body := strings.NewReader(`{"data":"ENCRYPTED_PAYLOAD"}`)
req, _ := http.NewRequest("POST", url, body)
req.Header.Set("partner-code", "YOUR_PARTNER_CODE")
req.Header.Set("x-service-code", "vccb-qr")
req.Header.Set("Authorization", "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI…")
req.Header.Set("Content-Type", "application/json")
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/qr", {
method: "POST",
headers: {
"partner-code": "YOUR_PARTNER_CODE",
"x-service-code": "vccb-qr",
"Authorization": "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI…",
"Content-Type": "application/json",
},
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> |
x-service-code | ✅ | Mã dịch vụ lấy từ API Get Services (ví dụ: vccb-qr) |
Body
| Field | Type | Required | Description |
|---|---|---|---|
data | string | ✅ | Payload đã mã hóa AES-256-CBC dạng Hexadecimal |
Response
200 — Tạo QR thành công
| Field | Type | Description |
|---|---|---|
image_png_base64 | string | Chuỗi Base64 của ảnh QR PNG. Dùng trực tiếp trong <img src="data:image/png;base64,..."> |
qr_content | string | Chuỗi nội dung thô của mã QR — dùng để tự render nếu cần |