添加异步预订

<ph type="x-smartling-placeholder">

同步预订是指已确认或拒绝的预订 实时更新

异步预订是指由商家确认或 拒绝这些交易

预订在 可用性级别。这也意味着,对于指定的商家和服务 可以同时设置同步和异步可用性空档

要确定合适的实现方式,请先确定 您的广告资源属于:

异步预订使用条件

  • 在 Actions Center 上修改异步预订 支持。
  • 商家应能够通过 合作伙伴的在线系统(例如餐馆的主机面板)。调用 代表用户确定商家是否接受或 拒绝预订。
  • 支持商家建议的新预订时间。通过 必须在原始状态下接受或拒绝预订请求。

仅启用同步预订

标准实现默认为同步预订。请查阅 如需了解详情,请参阅预留端到端集成文档。

启用异步预订

如果部分或全部商家使用异步预订流程, 需要进行以下更改:

  • 确认模式:现在的所有可用性空档的表示形式 包含一个 confirmation_mode 字段,用于说明 该可用性空档的 ID 已确认。指定 每个可用性空档的 confirmation_mode 以下:

    • 在可用性 Feed 中,confirmation_mode 在 可用性级别
    • 在 Booking Server API 方法中,confirmation_mode 在 广告位级
    • 在 Real-Time Updates API 方法中,指定了 confirmation_mode 在可用性级别
  • 预订状态:预订的所有表示法都包含 status 字段,表示预订状态。三 引入了新的异步状态值:PENDING_CONFIRMATIONDECLINED_BY_MERCHANTFAILED。在下列情况下,请使用这些新的状态值: 处理异步预订的创建、拒绝和失败。
  • 预订更新:对预订订单状态 应通过 Booking Notification API 的 bookings.patch 方法。

下图显示了如何使用确认模式和预订状态 使用典型的异步预订互动功能

<ph type="x-smartling-placeholder">
</ph> 图 1:异步预订流程
图 1:异步预订流程
  1. 可用性 Feed 已更新,每个可用性空档的 已指定确认模式。请务必将这些信息 这样我们就可以向该 Feed 说明预订的异步性质 在流程的早期阶段就吸引用户
  2. 时间 BatchAvailabilityLookupCheckAvailability 就会传递确认模式,理想情况下是将相同的确认模式 返回。这样可确保系统向用户显示恰当的广告内容。
  3. 时间 CreateBooking 则我们将确认模式传递给 指示预期的确认模式。如果异步预订 请求提交后,系统将返回预订状态 PENDING_MERCHANT_CONFIRMATION
  4. 当商家接受或拒绝预订请求后,预订 系统会通过 Booking Notification API 的实时更新功能更新状态, bookings.patch 方法。如果您想自动拒绝 及时回复,通过上述实时更新 方法。

可用性 Feed

在可用性 Feed 中,指定每个空档是同步还是同步 异步。为此,请设置新的 confirmation_mode 字段。

<ph type="x-smartling-placeholder">
// 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(巴拉圭时间) 或 CheckAvailabilityResponse (CA),则返回confirmation_mode 并通过 BatchAvailabilityLookupRequestCheckAvailabilityRequest

BAL-Async

{
  "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-Sync

{
  "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-Async

{
  "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-Sync

{
  "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中, 返回所提供的预订汇总空档的当前 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 。这适用于以下方法:

Inventory 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

预订状态的异步更新应通过预订功能进行 Notification API bookings.patch 方法。

更新状态时,请确保将status字段名称包含在 updateMask

状态 说明
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, 指定 booking_failure。如果将状态设置为其他任何值 系统会忽略 booking_failure

<ph type="x-smartling-placeholder">
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"}

电子邮件通知

对于异步预订,有五种可能的电子邮件与 发送给用户的预订状态信息。

<ph type="x-smartling-placeholder">
  • PENDING_MERCHANT_CONFIRMATION
  • CONFIRMED
  • DECLINED_BY_MERCHANT
  • FAILED
  • CANCELED