> For the complete documentation index, see [llms.txt](https://developer.gotadi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.gotadi.com/vietnamese/doi-tac-b2b2c/phuong-thuc-api/xu-ly-booking-journey.md).

# Xử lý BOOKING JOURNEY

### 1. API commit

* Khi gọi API Commit, sẽ được tính là bắt đầu một luồng đặt chỗ. Cần đảm bảo rằng hành trình đặt chỗ đã thực sự kết thúc trước khi tạo một luồng đặt chỗ mới.
* API Commit chỉ có nhiệm vụ kích hoạt hai hành động: thanh toán và xuất vé. Không thể chỉ sử dụng API Commit để xác định kết thúc một hành trình đặt chỗ mà còn phải kết hợp với API booking-detail [Booking API](/vietnamese/doi-tac-b2b2c/phuong-thuc-api/flight/booking-api.md#id-3api-lay-chi-tiet-thong-tin-booking) (mình sẽ chuyển sang sử dụng API final-booking-detail [/pages/9mDZFrbWTlSK6y2kstDH#id-5.-api-lay-chi-tiet-booking-sau-khi-xuat-ve](https://developer.gotadi.com/vietnamese/doi-tac-b2b2c/phuong-thuc-api/pages/9mDZFrbWTlSK6y2kstDH#id-5.-api-lay-chi-tiet-booking-sau-khi-xuat-ve "mention") theo khuyến cáo bên dưới trong document này).

### 2. API final booking detail

* API final-detail-booking được sử dụng để xác định trạng thái của một  \
  booking thông qua các status sau:
  * Payment statuses
  * Issued statuses
* API final-detail-booking này bổ sung thêm tính năng xử lý giữa các trường hợp thành công và thất bại. Cụ thể, trong trường hợp thành công (happy case), API sẽ ngay lập tức trả về kết quả. Trong trường hợp thất bại (failure case), API sẽ tự động thử lại để lấy trạng thái mới nhất của booking và trả về kết quả đến khi hết thời gian đặt sẵn.
* Các trường hợp được coi là hành trình booking đã kết thúc và có thể  \
  bắt đầu một hành trình mới:
  * Thanh toán thất bại: **paymentStatus** = <mark style="color:red;">**failed**</mark>
  * Thanh toán thành công và xuất vé thành công: **paymentStatus** = <mark style="color:green;">**Success**</mark> và **issueStatus** = <mark style="color:green;">**Success**</mark>
* Các cases được consider là booking journey chưa kết thúc, cần hold và xử lý tiếp.
  * Thanh toán thành công: **paymentStatus** = <mark style="color:green;">**Success**</mark> and **issueStatus&#x20;**<mark style="color:red;">**!=**</mark> <mark style="color:green;">**Success**</mark>

### 3. Khuyến cáo

* Khi gọi API Commit, có thể gặp một số thông báo lỗi ngoài bảng mã lỗi (ví dụ: lỗi không gọi được API, lỗi timeout, thời gian phản hồi quá lâu...). Người dùng cần sử dụng API final-booking-detail để xác định trạng thái của một booking.
* Sau khi get-final-booking-detail nếu: **paymentStatus =&#x20;**<mark style="color:green;">**success**</mark> mà **issueStatus&#x20;**<mark style="color:red;">**!=**</mark> <mark style="color:green;">**success**</mark> vẫn nên retry `GET` **final-booking-detail** để lấy được status đúng nhất.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.gotadi.com/vietnamese/doi-tac-b2b2c/phuong-thuc-api/xu-ly-booking-journey.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
