「同步預訂」是指即時確認或拒絕的預訂。
「非同步預訂」是指商家稍後確認或拒絕的預訂。
預訂是在供應情形層級指定為同步或非同步。這也代表特定商家和服務可能會出現同步和非同步的供應時段。
如要判斷適當的導入方式,請先確定您的廣告空間屬於哪個類別:
非同步預訂條件
- 不支援修改 Actions Center 上的非同步預訂。
- 商家應能透過合作夥伴的線上系統 (例如餐廳的代管面板) 接受或拒絕預訂。「不」可以代表使用者呼叫商家來判斷商家是否接受或拒絕預訂。
- 不支援商家提議新的預訂時間,您必須以原始狀態接受或拒絕預訂要求。
只啟用同步預訂功能
標準導入作業預設為同步預訂。詳情請參閱預留項目端對端整合說明文件。
啟用非同步預訂
如果部分或所有商家採用非同步預訂流程,則必須進行下列變更:
-
確認模式:供應時段的所有表示法現在都包含
confirmation_mode
欄位,說明系統確認該供應時段的預訂方式。請為以下項目指定每個供應時段的confirmation_mode
:- 在供應情形動態饋給中,「
confirmation_mode
」是在供應情形層級指定 - 在 Booking Server API 方法中,
confirmation_mode
是在時段層級指定 - 在 Real-Time Updates API 方法中,
confirmation_mode
是在可用性層級指定
- 在供應情形動態饋給中,「
- 預訂狀態:所有預訂表示法都包含代表預訂狀態的
status
欄位。我們推出了三個新的非同步狀態值:PENDING_CONFIRMATION
、DECLINED_BY_MERCHANT
和FAILED
。處理非同步預訂的建立作業、拒絕項目和失敗項目時,請使用這些新狀態值。 - 預訂更新:所有對預訂狀態的非同步更新都應透過 Booking Notification API 的 bookings.patch 方法回報。
下圖顯示確認模式和預訂狀態在一般非同步預訂互動中的使用方式。
![圖 1:非同步預訂流程](https://developers-dot-devsite-v2-prod.appspot.com/static/actions-center/images/enabling_async_1.png?authuser=7&hl=zh-tw)
- 供應情形動態饋給已更新,以便指定每個供應時段的確認模式。請務必在動態饋給中提供這項資訊, 以便我們在預訂流程中,盡早向使用者說明 該預訂可能無法即時確認的非同步性質。
- 呼叫
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
,並指定 delivery_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