Skip to main content

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:

FieldTypeRequiredDescription
ve_idnumber✅ YesBooking ID
hanh_khach_idnumber✅ YesPassenger ID
hostring✅ YesNew last name (UPPERCASE)
tenstring✅ YesNew first name (UPPERCASE)
danh_xungnumber✅ YesTitle: 1 = Mr, 2 = Mrs, 3 = Ms
xac_nhanstring✅ YesConfirm flag ("" = preview)
tong_tiennumber✅ YesTotal 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:

FieldTypeDescription
tong_tiennumberTotal payment amount
phi_thay_doinumberName 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

CodeVietnameseEnglish
1ÔngMr
2Mrs
3Ms

🔄 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
})
});

Prerequisites:

  • 02-GET-DETAILS.md - Get passenger ID

After:

  • 03-PAYMENT.md - Pay for HOLD booking
  • 02-GET-DETAILS.md - Verify name updated