「同步預訂」是指即時確認或拒絕的預訂。
非同步預訂的定義是指商家稍後確認或拒絕的預訂。
預訂作業是在供應情形層級指定為同步或非同步。這也代表了特定商家和服務可含有同步和非同步可用性運算單元。
為了決定適當的實作方式,請先找出商品目錄所屬的類別:
非同步預訂條件
- 不支援透過「透過 Google 預訂」進行非同步預訂。
- 不支援需要付款的非同步預訂。
- 商家應該能夠透過合作夥伴的線上系統 (例如餐廳的代管面板) 接受或拒絕預訂。「請勿」代表使用者致電商家,判斷商家是否接受或拒絕預訂。
- 不支援商家提議新的預訂時間,預訂要求必須在原始狀態接受或拒絕。
只啟用同步預訂功能
標準導入作業預設為同步預訂。詳情請參閱端對端整合指南。
啟用非同步預訂
如有部分或所有商家使用非同步預訂流程,則必須進行下列變更:
-
確認模式:播映資訊版位的所有表示法現在都包含
confirmation_mode
欄位,說明系統如何確認該供應時段的預訂。請按照下列條件指定每個可用性運算單元的confirmation_mode
:- 請在供應情形動態饋給的
confirmation_mode
中指定供應情形 - 在 Booking Server API 方法中,
confirmation_mode
會在版位層級指定 - 在即時更新 API 方法中,
confirmation_mode
是以可用性層級指定
- 請在供應情形動態饋給的
- 預訂狀態:預訂的所有代表都包含
status
欄位,代表預訂狀態。已引入三個新的非同步狀態值:PENDING_CONFIRMATION
、DECLINED_BY_MERCHANT
和FAILED
。在處理非同步預訂的建立、拒絕和失敗時,請使用這些新的狀態值。 - 預訂更新:所有預訂狀態的非同步更新都必須透過 Booking Notification API 的 bookings.patch 方法回報。
下圖說明確認模式和預訂狀態在一般非同步預訂互動中的使用方式。
- 供應情形動態饋給已更新,指定每個可用性時段的確認模式。請務必在動態饋給中提供這項資訊,以便在使用者流程的早期階段,事先向使用者說明預訂的非同步性質。
- 呼叫
BatchAvailabilityLookup
或CheckAvailability
時,我們會傳遞確認模式,理想情況下是傳回相同的確認模式。以確保使用者看到適當的訊息。 - 呼叫
CreateBooking
時,我們會傳遞確認模式,指出預期的確認模式。提交非同步預訂要求時,系統會傳回預訂狀態為PENDING_MERCHANT_CONFIRMATION
。 - 當商家接受或拒絕預訂要求時,就會透過即時更新 Booking Notification API 的 bookings.patch 方法更新預訂狀態。如要自動拒絕未即時回應的預訂,請使用相同的即時更新方法進行。
供應情形動態饋給
在供應情形動態饋給中,指定每個時段是同步還是非同步。如要這麼做,請設定新的 confirmation_mode
欄位。
// Mode by which bookings for an availability slot are confirmed. // enum ConfirmationMode { // The confirmation mode was not specified. // Synchronous confirmation will be assumed. CONFIRMATION_MODE_UNSPECIFIED = 0; // Bookings for this availability will be confirmed synchronously. CONFIRMATION_MODE_SYNCHRONOUS = 1; // Bookings for this availability will be confirmed asynchronously. CONFIRMATION_MODE_ASYNCHRONOUS = 2; }
如未指定模式,系統會假設確認模式為同步,但我們強烈建議您明確指定模式,因為這樣能避免意外忽略任何方式。
非同步
{ "availability": [ { "merchant_id": "10001", "service_id": "1000", "spots_open": 3, "spots_total": 3, "duration_sec": 3600, "start_sec": 1535806800, "resources": { "party_size": 4 }, "confirmation_mode": "CONFIRMATION_MODE_ASYNCHRONOUS" } ] }
同步
{ "availability": [ { "merchant_id": "10001", "service_id": "1000", "spots_open": 3, "spots_total": 3, "duration_sec": 3600, "start_sec": 1535806800, "resources": { "party_size": 4 }, "confirmation_mode": "CONFIRMATION_MODE_SYNCHRONOUS" } ] }
非同步與同步
{ "availability": [ { "merchant_id": "10001", "service_id": "1000", "spots_open": 3, "spots_total": 3, "duration_sec": 3600, "start_sec": 1535806800, "resources": { "party_size": 4 }, "confirmation_mode": "CONFIRMATION_MODE_SYNCHRONOUS" }, { "merchant_id": "10002", "service_id": "1000", "spots_open": 4, "spots_total": 4, "duration_sec": 3600, "start_sec": 1535806800, "resources": { "party_size": 2 }, "confirmation_mode": "CONFIRMATION_MODE_ASYNCHRONOUS" } ] }
預訂伺服器
BatchAvailabilityLookup 或 CheckAvailability
在 BatchAvailabilityLookupResponse
(BAL) 或 CheckAvailabilityResponse
(CA) 中,傳回您在供應情形動態饋給中指定的 confirmation_mode
,然後透過 BatchAvailabilityLookupRequest
或 CheckAvailabilityRequest
傳遞。
BAL-非同步
{ "slot_time_availability": [ { "slot_time": { "duration_sec": "3600", "resource_ids": { "party_size": 3 }, "service_id": "1000", "start_sec": "1546458300", "confirmation_mode": "CONFIRMATION_MODE_ASYNCHRONOUS" }, "available": true } ] }
BAL-同步
{ "slot_time_availability": [ { "slot_time": { "duration_sec": "3600", "resource_ids": { "party_size": 3 }, "service_id": "1000", "start_sec": "1546458300", "confirmation_mode": "CONFIRMATION_MODE_SYNCHRONOUS" }, "available": true } ] }
CA-非同步
{ "slot": { "duration_sec": "3600", "merchant_id": "317652", "resources": { "party_size": 3 }, "service_id": "1000", "start_sec": "1546458300", "confirmation_mode": "CONFIRMATION_MODE_ASYNCHRONOUS" }, "count_available": 1, "duration_requirement": "DO_NOT_SHOW_DURATION" }
CA-同步
{ "slot": { "duration_sec": "3600", "merchant_id": "317652", "resources": { "party_size": 3 }, "service_id": "1000", "start_sec": "1546458300", "confirmation_mode": "CONFIRMATION_MODE_SYNCHRONOUS" }, "count_available": 1, "duration_requirement": "DO_NOT_SHOW_DURATION" }
CreateBooking
請務必使用以下可用選項,傳回預訂的正確狀態:
// Status of a booking. // // Updating booking status does not change the status of the associated payment. // Prepayment status updates should be done using the PrepaymentStatus enum. enum BookingStatus { // Not specified. BOOKING_STATUS_UNSPECIFIED = 0; // Booking has been confirmed CONFIRMED = 1; // Booking is awaiting confirmation by the merchant before it can transition // into CONFIRMED status. Only applicable to non-payments Dining or // Beauty verticals. PENDING_MERCHANT_CONFIRMATION = 2; // Booking has been canceled on behalf of the user. // The merchant can still trigger a manual refund. CANCELED = 3; // User did not show for the appointment NO_SHOW = 4; // User did not show for the appointment in violation of the cancellation // policy. NO_SHOW_PENALIZED = 5; // Booking could not be completed by the async backend due to a failure. FAILED = 6; // Booking was asynchronously declined by the merchant. Only applicable to // non-payments Dining or Beauty verticals. DECLINED_BY_MERCHANT = 7; }
在 CreateBookingResponse
中,針對 CreateBookingRequest 中提供的預訂匯總時段,傳回目前的 confirmation_mode
。此外,如果預訂作業為非同步狀態,請將 status
設為 PENDING_MERCHANT_CONFIRMATION
。請確保 confirmation_mode
是使用者的用途,以及「透過 Google 預訂」預期的功能,以免造成使用者混淆。
非同步
{ "booking": { "slot": { "duration_sec": "3600", "merchant_id": "100001", "resources": { "party_size": 2 }, "service_id": "1000", "start_sec": "1546647234", "confirmation_mode": "CONFIRMATION_MODE_ASYNCHRONOUS" }, "user_information": { "email": "johnsmith@gmail.com", "family_name": "John", "given_name": "Smith", "telephone": "+1 800-123-4567", "user_id": "2017492857928759285" }, "payment_information": { "prepayment_status": "PREPAYMENT_NOT_PROVIDED" }, "status": "PENDING_MERCHANT_CONFIRMATION" } }
同步
{ "booking": { "slot": { "duration_sec": "3600", "merchant_id": "100001", "resources": { "party_size": 2 }, "service_id": "1000", "start_sec": "1546647234", "confirmation_mode": "CONFIRMATION_MODE_SYNCHRONOUS" }, "user_information": { "email": "johnsmith@gmail.com", "family_name": "John", "given_name": "Smith", "telephone": "+1 800-123-4567", "user_id": "2017492857928759285" }, "payment_information": { "prepayment_status": "PREPAYMENT_NOT_PROVIDED" }, "status": "CONFIRMED" } }
UpdateBooking
非同步版本的初始版本中,使用者無法修改現有的預訂。使用者應改為取消預訂並建立新的預訂。
即時更新
如要即時更新供應情形,請指定 confirmation_mode
。這適用於下列方法:
廣告空間 RTU (ReplaceServiceAvailability 或 BatchReplaceServiceAvailability)
使用 availability.replace
(批次) 方法或 services.availability.replace
方法,在 Availability
中將 confirmation_mode
設為 CONFIRMATION_MODE_ASYNCHRONOUS
非同步
{ "extendedServiceAvailability": [ { "merchantId": "1001", "serviceId": "12310", "startTimeRestrict": "2014-10-02T15:01:23.045123456Z", "endTimeRestrict": "2014-10-02T19:01:23.045123456Z", "availability": [ { "startTime": "2014-10-02T15:30:00.00Z", "duration": "3600s", "spotsOpen": "0", "spotsTotal": "2", "availabilityTag": "1000001", "confirmation_mode": "CONFIRMATION_MODE_ASYNCHRONOUS" } ] } ] }
同步
{ "extendedServiceAvailability": [ { "merchantId": "1001", "serviceId": "12310", "startTimeRestrict": "2014-10-02T15:01:23.045123456Z", "endTimeRestrict": "2014-10-02T19:01:23.045123456Z", "availability": [ { "startTime": "2014-10-02T15:30:00.00Z", "duration": "3600s", "spotsOpen": "0", "spotsTotal": "2", "availabilityTag": "1000001", "confirmation_mode": "CONFIRMATION_MODE_SYNCHRONOUS" } ] } ] }
非同步與同步
{ "extendedServiceAvailability": [ { "merchantId": "1001", "serviceId": "12310", "startTimeRestrict": "2014-10-02T15:01:23.045123456Z", "endTimeRestrict": "2014-10-02T19:01:23.045123456Z", "availability": [ { "startTime": "2014-10-02T15:30:00.00Z", "duration": "3600s", "spotsOpen": "0", "spotsTotal": "2", "availabilityTag": "1000001", "confirmation_mode": "CONFIRMATION_MODE_ASYNCHRONOUS" }, { "startTime": "2014-10-03T11:00:00.00Z", "duration": "5400s", "spotsOpen": "1", "spotsTotal": "1", "availabilityTag": "1000002", "confirmation_mode": "CONFIRMATION_MODE_SYNCHRONOUS" } ] } ] }
Booking Notification API
預訂狀態的非同步更新應透過 Booking Notification API bookings.patch 方法進行。
更新狀態時,請務必在 updateMask
中加入 status
欄位名稱。
狀態 | 說明 |
---|---|
CONFIRMED | 商家已確認預訂 |
FAILED | 合作夥伴無法向商家確認或拒絕預訂 |
DECLINED_BY_MERCHANT | 商家拒絕預訂 |
Request: PATCH https://mapsbooking.googleapis.com/v1alpha/notification/partners/<PARTNER_ID>/bookings/<BOOKING_ID>?updateMask=status Body: {"name":"partners/<PARTNER_ID>/bookings/<BOOKING_ID>", "status":"DECLINED_BY_MERCHANT"}
如果預訂失敗,請將預訂狀態設為 FAILED
,並指定預訂_failure。如果狀態設為其他狀態,則系統會忽略 booking_failure
。
Request: PATCH https://mapsbooking.googleapis.com/v1alpha/notification/partners/<PARTNER_ID>/bookings/<BOOKING_ID>?updateMask=status&booking_failure.cause="SLOT_UNAVAILABLE" Body: {"name":"partners/<PARTNER_ID>/bookings/<BOOKING_ID>", "status":"FAILED"}
電子郵件通知
對於非同步的預訂,您可以透過五個可能與預訂狀態相關的電子郵件,傳送電子郵件給使用者。
PENDING_MERCHANT_CONFIRMATION
CONFIRMED
DECLINED_BY_MERCHANT
FAILED
CANCELED