Create VA
POST /openapi/v1/va/va-account/create
Tạo tài khoản ảo (Virtual Account) cho Merchant để nhận thanh toán chuyển khoản.
Gọi Get Services trước để lấy service_code (dùng làm header x-service-code). Truyền qr-pay sẽ chạy luồng tạo QR Pay.
Payload trước khi mã hóa:
{
"request_id": "8bd13901-b0f1-42c1-b38f-59cd0d8faff8",
"bank_account_no": "31052426",
"internal_code": "KH_0000024",
"qr_type": "qrpay"
}
internal_codelà Merchant CIF — thường trùng vớiPartner-Code(vd sandbox:KH_0000024), không phải số ngẫu nhiên.va_typetự gán"M"khix-service-code="qr-pay";fixed_amounttùy chọn (bỏ qua nếu VA động).
| Trường | Bắt buộc | Mô tả |
|---|---|---|
request_id | ✅ | Mã định danh duy nhất cho mỗi yêu cầu khởi tạo. |
bank_account_no | ✅ | Số tài khoản ngân hàng gốc của Merchant. |
internal_code | ✅ | Merchant CIF — mã định danh khách hàng tại ngân hàng (thường trùng Partner-Code). |
va_type | ✕ | Loại Virtual Account (tùy chọn, tự động gán "M" khi x-service-code="qr-pay"). |
fixed_amount | ✕ | Số tiền cố định định danh cho VA/QR (nếu có). |
qr_type | ✕ | Loại QR: "qrpay" nếu là QR Pay, mặc định "ibft". |
- cURL
- Python
- Go
- JavaScript
curl --location '<base_url>/openapi/v1/va/va-account/create' \
--header 'Partner-Code: YOUR_PARTNER_CODE' \
--header 'x-service-code: SERVICE_CODE' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1…' \
--data '{
"data": ENCRYPTED_PAYLOAD
}'
import requests
url = "<base_url>/openapi/v1/va/va-account/create"
payload = {"data": "ENCRYPTED_PAYLOAD"}
headers = {
"Partner-Code": "YOUR_PARTNER_CODE",
"x-service-code": "SERVICE_CODE",
"Content-Type": "application/json",
"Authorization": "Bearer eyJhbGciOiJSUzI1…",
}
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/va/va-account/create"
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", "SERVICE_CODE")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer eyJhbGciOiJSUzI1…")
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/va/va-account/create", {
method: "POST",
headers: {
"Partner-Code": "YOUR_PARTNER_CODE",
"x-service-code": "SERVICE_CODE",
"Content-Type": "application/json",
"Authorization": "Bearer eyJhbGciOiJSUzI1…",
},
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) |
x-service-code | ✅ | Mã dịch vụ ngân hàng (lấy từ API Get Services). Truyền qr-pay sẽ chạy luồng tạo QR Pay. |
Content-Type | ✅ | application/json |
Authorization | ✅ | Bearer <access_token> từ Login |
Body
| Field | Type | Required | Description |
|---|---|---|---|
data | string | ✅ | Payload đã mã hóa AES-256-CBC dạng Hexadecimal |
Response
200 — Tạo VA thành công
| Field | Type | Description |
|---|---|---|
va_account_no | string | Số tài khoản ảo được tạo (vd: VA100023312) |
request_id | string | Mã định danh yêu cầu |
ref_id | int | Mã định danh tài khoản ảo |
[!NOTE] Quy trình xử lý dữ liệu hệ thống:
- Data gửi hệ thống xử lý: Được bổ sung thêm
qr_type("qrpay"nếu là QR Pay / mặc định"ibft"),va_type(sẽ luôn gán"M"nếu truyềnx-service-code="qr-pay"), vàfixed_amount(nếu có).- L ưu DB MMS (
res_partner_bank): Khix-service-code="qr-pay", cộtacc_typetrong DB được lưu là'qr_pay'thay vì'va', đồng thời cập nhật query check trùng số VA/QR áp dụng cho cả 2 loại này.