Skip to main content

Issue Ticket - Xuất Vé Trực Tiếp

API Endpoint: POST /api/v1/services/booking/v1/dat-chuyen


📋 Overview

Xuất vé trực tiếp (book và issue trong 1 request). Tạo booking với trạng thái ISSUED (trang_thai: 1).

Difference from HOLD:

  • HOLD (trang_thai: 0): Giữ chỗ, cần thanh toán sau
  • ISSUE (trang_thai: 1): Xuất vé luôn, trừ tiền ngay

Flow:

Search → Issue (trang_thai: 1) → Done

vs

Search → Hold (trang_thai: 0) → Payment → ISSUED

🔌 API Specification

Endpoint

POST {{base_url}}/api/v1/services/booking/v1/dat-chuyen

Same endpoint as HOLD, only difference is trang_thai field.

Headers

{
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Bearer {access_token}"
}

Request Body

{
"api": "VJ",
"nhieu_chang": 0,
"chuyen_bay": [
{
"index": 1,
"uuid": "852ffde2-aeb0-11f0-8b81-86d224031662",
"phi_dai_ly": 0,
"index_hang_cho": 0,
"loai_phi_dai_ly": "Cơ bản"
}
],
"hanh_khach": [
{
"index": 1,
"ho": "NGUYEN VAN",
"ten": "TEST",
"email": "test@example.com",
"so_dien_thoai": "0987654321",
"ngay_sinh": "01-01-1990",
"the_thanh_vien": "",
"loai_hanh_khach": 1,
"danh_xung": 1,
"cha_me_id": null,
"ho_chieu": null
}
],
"thong_tin_booker": {
"ho": "TRAN THI",
"ten": "BOOKER",
"email": "booker@example.com",
"so_dien_thoai": "0912345678"
},
"dich_vu": [],
"cho_ngoi": [],
"ma_khuyen_mai": "",
"trang_thai": 1,
"xac_nhan_ve_dup": "",
"xac_nhan_thay_doi_gia": "",
"tong_gia_ve": 0,
"xac_nhan_cho_du_bi": ""
}

Key Difference from HOLD:

"trang_thai": 1  // ← 1 = ISSUE (xuất vé), 0 = HOLD (giữ chỗ)

All other fields are identical to HOLD request. See 05-HOLD-BOOKING.md for detailed field descriptions.


✅ Success Response

Status: 200 OK

{
"message": "Đặt chỗ thành công. ",
"data": {
"ve": {
"id": 85,
"pnr": "XYZ123",
"uuid": "abc-def-123",
"trang_thai": 1,
"hang_bay": "VJ",
"so_hieu": "VJ 9001",
"hanh_trinh": "SGN - HAN",
"ngay_bay": "25-10-2025 08:00:00",
"gia_net": 4189100,
"thue": 630500,
"ho_ten_booker": "TRAN THI BOOKER",
"nguoi_dai_dien": "NGUYEN VAN TEST",
"email_1": "test@example.com",
"ngay_book": "22-10-2025 02:05:00",
"ngay_xuat": "22-10-2025 02:05:00"
},
"hanh_khach": [...],
"chang_bay": [...]
},
"status": "success",
"code": 200
}

Key Response Fields:

FieldTypeDescription
data.ve.trang_thainumberStatus: 1 = ISSUED
data.ve.pnrstringPNR - Booking reference
data.ve.ngay_xuatstringIssue date (ticket issued immediately)
data.ve.ngay_het_hanstring/nullNo payment deadline (already paid)

💡 Example: cURL

curl -X POST "{{base_url}}/api/v1/services/booking/v1/dat-chuyen" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {access_token}" \
-d '{
"api": "VJ",
"nhieu_chang": 0,
"chuyen_bay": [{
"index": 1,
"uuid": "852ffde2-aeb0-11f0-8b81-86d224031662",
"phi_dai_ly": 0,
"index_hang_cho": 0,
"loai_phi_dai_ly": "Cơ bản"
}],
"hanh_khach": [{
"index": 1,
"ho": "NGUYEN VAN",
"ten": "TEST",
"email": "test@example.com",
"so_dien_thoai": "0987654321",
"ngay_sinh": "01-01-1990",
"the_thanh_vien": "",
"loai_hanh_khach": 1,
"danh_xung": 1,
"cha_me_id": null,
"ho_chieu": null
}],
"thong_tin_booker": {
"ho": "TRAN THI",
"ten": "BOOKER",
"email": "booker@example.com",
"so_dien_thoai": "0912345678"
},
"dich_vu": [],
"cho_ngoi": [],
"ma_khuyen_mai": "",
"trang_thai": 1,
"xac_nhan_ve_dup": "",
"xac_nhan_thay_doi_gia": "",
"tong_gia_ve": 0,
"xac_nhan_cho_du_bi": ""
}'

⚠️ Important Notes

1. HOLD vs ISSUE

FieldHOLDISSUE
trang_thai01
StatusGiữ chỗĐã xuất vé
PaymentLater (MMB)Immediate (F2 wallet)
Deadline~4 hoursNone (already paid)
Can modifyYes (before payment)Limited

2. Payment is Automatic

When using trang_thai: 1:

  • F2 wallet is charged immediately
  • No need to call /thanh-toan API
  • Booking is created in ISSUED state directly

3. Wallet Balance Required

F2 wallet balance >= ticket price + services + seats

If insufficient, API will return error.

4. Cannot Undo

Once ISSUED:

  • Cannot cancel freely
  • Can only VOID (within 24h) or REFUND
  • May have change/refund fees

5. When to Use ISSUE vs HOLD

Use ISSUE when:

  • Want immediate ticket
  • Sure about booking details
  • Wallet has sufficient balance

Use HOLD when:

  • Need time to add services/seats
  • Unsure about passenger details
  • Want to confirm before payment

🔄 Comparison Table

FeatureHOLD (trang_thai: 0)ISSUE (trang_thai: 1)
Endpoint/dat-chuyen/dat-chuyen
Request bodyAlmost identicalAlmost identical
trang_thai01
Payment timingLater (via /thanh-toan)Immediate
Wallet chargedNoYes
Deadline~4 hoursNone
Can add servicesYes (before payment)Depends on route
Typical useReview before payQuick booking

🐛 Common Issues

Insufficient Balance

Response:

{
"message": "Số dư không đủ",
"status": "error"
}

Solution:

  • Use HOLD instead (trang_thai: 0)
  • Top up F2 wallet

Flight Not Available

Response:

{
"message": "Chuyến bay không còn chỗ",
"status": "error"
}

Cause: Flight UUID expired or seats sold out

Solution: Search flights again


📊 Booking Flow Comparison

Option 1: Direct Issue (this API)

1. Search flights
2. Issue ticket (trang_thai: 1)
↓ Wallet charged immediately
3. Done - Ticket issued

Option 2: Hold then Pay

1. Search flights
2. Hold booking (trang_thai: 0)
3. [Optional] Add services/seats
4. Payment (/thanh-toan)
↓ Wallet charged
5. Done - Ticket issued

Before Issue:

  • ../authentication/01-AUTHENTICATION.md - Get access token
  • 02-SEARCH-FLIGHTS.md - Get flight UUID

After Issue:

  • ../manage-booking/GET-DETAILS.md - View booking details
  • ../manage-booking/LIST-BOOKINGS.md - List all bookings

Alternative:

  • 05-HOLD-BOOKING.md - Hold booking instead of issuing
  • ../manage-booking/PAYMENT.md - Pay HOLD booking later

📝 Notes

  • Same API endpoint as HOLD, only trang_thai differs
  • Payment is automatic when trang_thai: 1
  • Charges F2 wallet immediately
  • No payment deadline (already paid)
  • Cannot be cancelled easily (only VOID/REFUND)
  • For flexible booking, use HOLD instead
  • All field requirements same as HOLD (see 04-HOLD-BOOKING.md)