Update Passenger - Đổi Tên Hành Khách
API Endpoint: POST /api/v1/services/booking/v1/cap-nhat-hanh-khach
📋 Overview
Update passenger name information for VietJet booking.
Use Case:
- Fix name spelling errors
- Update passenger title
- Correct name format
Supported: Preview and confirm modes
🔌 API Specification
Endpoint
POST {{base_url}}/api/v1/services/booking/v1/cap-nhat-hanh-khach
Headers
{
"Content-Type": "application/json",
"Authorization": "Bearer {access_token}"
}
Preview Mode
Calculate name change fee before updating.
Request Body
{
"ve_id": 659,
"hanh_khach_id": 1698,
"ho": "NGUYEN",
"ten": "VAN A",
"danh_xung": 1,
"xac_nhan": "",
"tong_tien": 0
}
Fields:
| Field | Type | Required | Description |
|---|---|---|---|
ve_id | number | ✅ Yes | Booking ID |
hanh_khach_id | number | ✅ Yes | Passenger ID |
ho | string | ✅ Yes | New last name (UPPERCASE) |
ten | string | ✅ Yes | New first name (UPPERCASE) |
danh_xung | number | ✅ Yes | Title: 1 = Mr, 2 = Mrs, 3 = Ms |
xac_nhan | string | ✅ Yes | Confirm flag ("" = preview) |
tong_tien | number | ✅ Yes | Total amount (0 for preview) |
Response
{
"message": "Tổng tiền thanh toán là 14,396,400",
"data": {
"tong_tien": 14396400,
"phi_thay_doi": 9331600
},
"status": "success",
"code": 200
}
Response Fields:
| Field | Type | Description |
|---|---|---|
tong_tien | number | Total payment amount |
phi_thay_doi | number | Name change fee |
Confirm Mode
Execute passenger name update.
Request Body
{
"ve_id": 659,
"hanh_khach_id": 1698,
"ho": "NGUYEN",
"ten": "VAN A",
"danh_xung": 1,
"xac_nhan": "y",
"tong_tien": 14396400
}
Key Differences from Preview:
xac_nhan: "y"(confirm mode)tong_tien: 14396400(use fee from preview)
💡 Usage Notes
Name Format Rules
// ✅ Correct
"ho": "NGUYEN VAN"
"ten": "TEST"
// ❌ Wrong
"ho": "Nguyen Van" // Must be UPPERCASE
"ten": "test" // Must be UPPERCASE
Title Codes
| Code | Vietnamese | English |
|---|---|---|
1 | Ông | Mr |
2 | Bà | Mrs |
3 | Cô | Ms |
🔄 Example Flow
// 1. Get booking details
const booking = await getBookingDetails(ve_id);
const passenger = booking.hanh_khach[0];
// 2. Preview name change fee
const preview = await fetch('/cap-nhat-hanh-khach', {
method: 'POST',
body: JSON.stringify({
ve_id: booking.ve.id,
hanh_khach_id: passenger.id,
ho: "NGUYEN",
ten: "VAN A",
danh_xung: 1,
xac_nhan: "",
tong_tien: 0
})
});
const fee = preview.data.tong_tien;
console.log('Name change fee:', fee);
// 3. Confirm update
const result = await fetch('/cap-nhat-hanh-khach', {
method: 'POST',
body: JSON.stringify({
ve_id: booking.ve.id,
hanh_khach_id: passenger.id,
ho: "NGUYEN",
ten: "VAN A",
danh_xung: 1,
xac_nhan: "y",
tong_tien: fee
})
});
🔗 Related APIs
Prerequisites:
02-GET-DETAILS.md- Get passenger ID
After:
03-PAYMENT.md- Pay for HOLD booking02-GET-DETAILS.md- Verify name updated