履单操作架构

本页面介绍在使用 Ordering End-to-End 内置 Action API 时执行方式 Web 服务 (Ordering End-to-End API) 的载荷。 如需获取这些信息的机器可读版本,您可以下载 JSON 架构

基本类型

购物车

包含订单的详细信息,以及请求是自提还是送餐。购物车还包含配送详情、小费和配送地址。 Cart 对象在 Checkout AppRequest 中定义。您可以在 Checkout AppResponse 中添加购物车的副本

下表列出了 Cart 类型的属性:

媒体资源 类型 说明
@type 对比度

此对象的类型。如果父级 Cart 对象是 ProposedOrder 的一部分,请忽略此字段。

值:type.googleapis.com/google.actions.v2.orders.Cart

id String

购物车的可选 ID。

merchant Merchant

与此购物车关联的商家。

lineItems 列表<LineItem>

必填。

用户订购的商品或服务的列表。

不得少于 1 项

promotions 列表<Promotion>

此购物车中的促销优惠。目前仅支持一项促销活动。

notes String

有关订单或交货说明的备注。

extension FoodCartExtension

定义有关用户的详细信息,例如执行方式偏好设置。

以下示例展示了 Cart 元素:

示例 1

{
  "@type": "type.googleapis.com/google.actions.v2.orders.Cart",
  "merchant": {
    "id": "https://www.exampleprovider.com/merchant/id1",
    "name": "Cucina Venti"
  },
  "lineItems": [
    {
      "name": "Sizzling Prawns Dinner",
      "type": "REGULAR",
      "id": "sample_item_offer_id_1",
      "offerId": "https://www.exampleprovider.com/menu/item/offer/id1",
      "quantity": 1,
      "price": {
        "type": "ESTIMATE",
        "amount": {
          "currencyCode": "USD",
          "units": "16",
          "nanos": 750000000
        }
      },
      "subLines": [
        {
          "note": "Notes for this item."
        }
      ],
      "extension": {
        "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension",
        "options": [
          {
            "id": "sample_addon_offer_id_1",
            "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id1",
            "name": "Honey Mustard",
            "price": {
              "currencyCode": "USD"
            },
            "quantity": 1
          },
          {
            "id": "sample_addon_offer_id_2",
            "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id2",
            "name": "BBQ Sauce",
            "price": {
              "currencyCode": "USD",
              "nanos": 500000000
            },
            "quantity": 1
          }
        ]
      }
    }
  ],
  "extension": {
    "@type": "type.googleapis.com/google.actions.v2.orders.FoodCartExtension",
    "fulfillmentPreference": {
      "fulfillmentInfo": {
        "delivery": {
          "deliveryTimeIso8601": "P0M"
        }
      }
    },
    "location": {
      "coordinates": {
        "latitude": 37.788783,
        "longitude": -122.41384
      },
      "formattedAddress": "1350 CHARLESTON ROAD, MOUNTAIN VIEW, CA, United States",
      "zipCode": "94043",
      "city": "Mountain View",
      "postalAddress": {
        "regionCode": "US",
        "postalCode": "94043",
        "administrativeArea": "CA",
        "locality": "Mountain View",
        "addressLines": [
          "1350 Charleston Road"
        ]
      },
      "notes": "Gate code is #111"
    }
  }
}

示例 2

{
  "merchant": {
    "id": "https://www.exampleprovider.com/merchant/id1",
    "name": "Falafel Bite"
  },
  "lineItems": [
    {
      "name": "Pita Chips",
      "type": "REGULAR",
      "id": "sample_item_offer_id_1",
      "offerId": "https://www.exampleprovider.com/menu/item/offer/id1",
      "quantity": 1,
      "price": {
        "type": "ESTIMATE",
        "amount": {
          "currencyCode": "USD",
          "units": "2",
          "nanos": 750000000
        }
      },
      "subLines": [
        {
          "note": "Notes for this item."
        }
      ],
      "extension": {
        "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension",
        "options": [
          {
            "id": "sample_addon_offer_id_1",
            "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id1",
            "name": "Honey Mustard",
            "price": {
              "currencyCode": "USD"
            },
            "quantity": 1
          },
          {
            "id": "sample_addon_offer_id_2",
            "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id2",
            "name": "BBQ Sauce",
            "price": {
              "currencyCode": "USD",
              "nanos": 500000000
            },
            "quantity": 1
          }
        ]
      }
    },
    {
      "name": "Chicken Shwarma Wrap",
      "type": "REGULAR",
      "id": "sample_item_offer_id_2",
      "offerId": "https://www.exampleprovider.com/menu/item/offer/id2",
      "quantity": 1,
      "price": {
        "type": "ESTIMATE",
        "amount": {
          "currencyCode": "USD",
          "units": "8"
        }
      },
      "extension": {
        "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension"
      }
    },
    {
      "name": "Greek Salad",
      "type": "REGULAR",
      "id": "sample_item_offer_id_3",
      "offerId": "https://www.exampleprovider.com/menu/item/offer/id3",
      "quantity": 1,
      "price": {
        "type": "ESTIMATE",
        "amount": {
          "currencyCode": "USD",
          "units": "9",
          "nanos": 990000000
        }
      },
      "extension": {
        "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension"
      }
    },
    {
      "name": "Prawns Biryani",
      "type": "REGULAR",
      "id": "sample_item_offer_id_4",
      "offerId": "https://www.exampleprovider.com/menu/item/offer/id4",
      "quantity": 1,
      "price": {
        "type": "ESTIMATE",
        "amount": {
          "currencyCode": "USD",
          "units": "15",
          "nanos": 990000000
        }
      },
      "extension": {
        "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension"
      }
    }
  ],
  "extension": {
    "@type": "type.googleapis.com/google.actions.v2.orders.FoodCartExtension",
    "fulfillmentPreference": {
      "fulfillmentInfo": {
        "delivery": {
          "deliveryTimeIso8601": "P90M"
        }
      }
    },
    "location": {
      "coordinates": {
        "latitude": 37.788783,
        "longitude": -122.41384
      },
      "formattedAddress": "1350 CHARLESTON ROAD, MOUNTAIN VIEW, CA, United States",
      "zipCode": "94043",
      "city": "Mountain View",
      "postalAddress": {
        "regionCode": "US",
        "postalCode": "94043",
        "administrativeArea": "CA",
        "locality": "Mountain View",
        "addressLines": [
          "1350 Charleston Road"
        ]
      },
      "notes": "Gate code is #111"
    }
  }
}

联系信息

指定接收订单的人员的详细信息。它仅支持 AppResponse

下表列出了 Contact 类型的属性:

媒体资源 类型 说明
displayName String

订单接收人的姓名,您希望显示的姓名。如果未指定 firstName 和 lastName,请使用此字段。

示例:Lovefood Ordering

email String

订单接收人的电子邮件地址。

示例:ilovefood@example.com

firstName String

订单接收人的名字。

示例:Lovefood

lastName String

订单接收人的姓氏。

示例:Ordering

phoneNumber String

订单接收人的电话号码,包括国家/地区代码。

示例:+16501234567

emailVerified Boolean

指明接收订单的人是否使用自己的 Google 帐号登录。

以下示例展示了 Contact 元素:

示例

{
  "displayName": "Lovefood Ordering",
  "email": "ilovefood@example.com",
  "phoneNumber": "+16501234567"
}

CustomPushMessage

包含请求的 OrderUpdate

下表列出了 CustomPushMessage 类型的属性:

媒体资源 类型 说明
orderUpdate OrderUpdate

必填。

更新了订单信息。

以下示例展示了 CustomPushMessage 元素:

示例

{
  "orderUpdate": {
    "actionOrderId": "sample_action_order_id",
    "orderState": {
      "state": "IN_TRANSIT",
      "label": "Order is on the way"
    },
    "inTransitInfo": {
      "updatedTime": "2017-07-17T12:00:00Z"
    },
    "updateTime": "2017-07-17T12:00:00Z",
    "orderManagementActions": [
      {
        "type": "CUSTOMER_SERVICE",
        "button": {
          "title": "Contact customer service",
          "openUrlAction": {
            "url": "mailto:support@example.com"
          }
        }
      },
      {
        "type": "EMAIL",
        "button": {
          "title": "Email restaurant",
          "openUrlAction": {
            "url": "mailto:person@example.com"
          }
        }
      },
      {
        "type": "CALL_RESTAURANT",
        "button": {
          "title": "Call restaurant",
          "openUrlAction": {
            "url": "tel:+16505554679"
          }
        }
      }
    ],
    "receipt": {
      "userVisibleOrderId": "userVisibleId1234"
    },
    "infoExtension": {
      "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension",
      "estimatedFulfillmentTimeIso8601": "2017-07-17T13:00:00Z/2017-07-17T13:30:00Z"
    }
  }
}

DeliveryInfo

下表列出了 DeliveryInfo 类型的属性:

媒体资源 类型 说明
deliveryTimeIso8601 String

预计送货时间,采用 ISO 8601 时间戳格式:{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z”,或时长格式:“P(n)Y(n)M(n)DT(n)H(n)M(n)S”。例如,PT90M 表示时长 90 分钟。默认值 "PT0M" 表示首选送货时间尽可能短。参考文档:https://zh.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations。使用此方法可在结账响应期间更新预计送货时间。

示例:PT90M

以下示例展示了 DeliveryInfo 元素:

示例

{
  "deliveryTimeIso8601": "PT90M"
}

免责声明

下表列出了 Disclaimer 类型的属性:

媒体资源 类型 说明
predefinedMessage PredefinedMessage

必填。

在结账时显示预定义的免责声明消息。

feeAmount Money

合作伙伴将针对此订单向商家收取金额为 N 的费用。

feeAmountRange FeeAmountRange

合作伙伴将针对每笔订单向餐馆收取 N 到 M 的费用。

feePercent 编号

合作伙伴将针对此订单向商家收取 N% 的费用。

feePercentRange FeePercentRange

对于每笔订单,合作伙伴将向商家收取 N% 到 M% 的费用。

以下示例展示了 Disclaimer 元素:

示例 1

{
  "predefinedMessage": "NEW_YORK_DELIVERY_FEE_TIP_DISCLAIMER"
}

示例 2

{
  "predefinedMessage": "FEE_CHARGED_TO_RESTAURANT_DISCLOSURE"
}

示例 3

{
  "predefinedMessage": "FEE_CHARGED_TO_RESTAURANT_DISCLOSURE",
  "feePercent": 25
}

示例 4

{
  "predefinedMessage": "FEE_CHARGED_TO_RESTAURANT_DISCLOSURE",
  "feePercentRange": {
    "minFeePercent": 20,
    "maxFeePercent": 30
  }
}

示例 5

{
  "predefinedMessage": "FEE_CHARGED_TO_RESTAURANT_DISCLOSURE",
  "feeAmount": {
    "currencyCode": "AUD",
    "units": 2,
    "nanos": 500000000
  }
}

示例 6

{
  "predefinedMessage": "FEE_CHARGED_TO_RESTAURANT_DISCLOSURE",
  "feeAmountRange": {
    "minFeeAmount": {
      "currencyCode": "AUD",
      "units": 2,
      "nanos": 500000000
    },
    "maxFeeAmount": {
      "currencyCode": "AUD",
      "units": 10,
      "nanos": 0
    }
  }
}

错误

Error 类型具有以下可能的值:

  • CLOSED:该餐馆在点餐时不营业。
  • NO_CAPACITY:没有可用的服务容量(例如,高峰时段临时中断)。
  • NO_COURIER_AVAILABLE:由于配送人员有限,无法处理此订单。
  • REQUIREMENTS_NOT_MET:未满足接受订单的限制(例如购物车中商品数量下限)。
  • UNAVAILABLE_SLOT:订单无法按 DeliveryInfo 或 PickupInfo 指定的提前订单履行。
  • OUT_OF_SERVICE_AREA:无法将订单商品配送到用户的地址。
  • PROMO_EXPIRED:无法应用,因为促销活动已过期。
  • PROMO_NOT_APPLICABLE:通用错误代码,用于捕获无法应用促销代码的所有情况(如果所有其他促销代码错误均不适用)。
  • PROMO_NOT_RECOGNIZED:无法识别优惠券代码。
  • PROMO_ORDER_INELIGIBLE:当前订单不符合使用此优惠券的条件。
  • PROMO_USER_INELIGIBLE:当前用户不符合使用此优惠券的条件。
  • AVAILABILITY_CHANGED:商品已无货,或商品数量不足,无法履单。
  • INCORRECT_PRICE:费用或总价中的价格错误。
  • INVALID:订单项、FulfillmentOption 或 promotion 包含无效数据。
  • NOT_FOUND:找不到 PHONE、FulfillmentOption 或促销。
  • PRICE_CHANGED:商品的价格发生了变化。

FeeAmountRange

下表列出了 FeeAmountRange 类型的属性:

媒体资源 类型 说明
minFeeAmount Money

收取的费用金额下限。

maxFeeAmount Money

收取的费用金额的上限。

FeePercentRange

下表列出了 FeePercentRange 类型的属性:

媒体资源 类型 说明
minFeePercent 编号

收取的费用百分比下限。

maxFeePercent 编号

所收取的费用百分比上限。

FoodCartExtension

包含有关用户的详细信息,例如履单偏好设置。

下表列出了 FoodCartExtension 类型的属性:

媒体资源 类型 说明
@type 对比度

此扩展程序的类型。此字段始终设置为“type.googleapis.com/google.actions.v2.orders.FoodCartExtension”。

值:type.googleapis.com/google.actions.v2.orders.FoodCartExtension

contact Contact

接收订单的人员的联系信息。详细信息包括对方的姓名、电话号码和电子邮件地址。

fulfillmentPreference FulfillmentOption

必填。

用户的履单偏好设置。

location Location

在 CheckoutRequestMessage 中,此字段用于指定配送地址;如果订单旨在配送,则必须填写此地址。对于外卖或自提订单,消息中不包含此字段。

以下示例展示了 FoodCartExtension 元素:

示例 1

{
  "@type": "type.googleapis.com/google.actions.v2.orders.FoodCartExtension",
  "fulfillmentPreference": {
    "fulfillmentInfo": {
      "delivery": {
        "deliveryTimeIso8601": "P0M"
      }
    }
  },
  "location": {
    "coordinates": {
      "latitude": 37.788783,
      "longitude": -122.41384
    },
    "formattedAddress": "1350 CHARLESTON ROAD, MOUNTAIN VIEW, CA, United States",
    "zipCode": "94043",
    "city": "Mountain View",
    "postalAddress": {
      "regionCode": "US",
      "postalCode": "94043",
      "administrativeArea": "CA",
      "locality": "Mountain View",
      "addressLines": [
        "1350 Charleston Road"
      ]
    },
    "notes": "Gate code is #111"
  }
}

示例 2

{
  "@type": "type.googleapis.com/google.actions.v2.orders.FoodCartExtension",
  "fulfillmentPreference": {
    "fulfillmentInfo": {
      "pickup": {
        "pickupTimeIso8601": "P0M"
      }
    }
  },
  "contact": {
    "displayName": "Lovefood Ordering",
    "email": "ilovefood@example.com",
    "phoneNumber": "+16501234567"
  }
}

FoodErrorExtension

标识在处理请求时发生的一个或多个错误。 下表介绍了 FoodErrorExtension 类型的字段。错误可以在 CheckoutResponse 中发送。

下表列出了 FoodErrorExtension 类型的属性:

媒体资源 类型 说明
@type 对比度

必填。

此扩展程序的类型。

值:type.googleapis.com/google.actions.v2.orders.FoodErrorExtension

foodOrderErrors 列表<FoodOrderError>

必填。

一系列 FoodOrderError 对象,用于描述所发生的错误。建议每个购物车或每件商品出现一次错误。

不得少于 1 项

correctedProposedOrder ProposedOrder

foodOrderErrors.error = "UNAVAILABLE_SLOT", "PROMO_EXPIRED", "PROMO_NOT_APPLICABLE", "PROMO_NOT_RECOGNIZED", "PROMO_ORDER_INELIGIBLE", "PROMO_USER_INELIGIBLE", "AVAILABILITY_CHANGED", "INCORRECT_PRICE", "INVALID", "NOT_FOUND", or "PRICE_CHANGED" 时是必需的。

包含更正内容的新 ProposedOrder。如果原始 ProposedOrder 存在可恢复的错误,则返回此对象。例如,购物车中一个或多个订单项的价格变动就是可恢复的错误。具有有效 ProposedOrder 的可恢复错误会进入确认阶段,而无需用户查看其购物车。

paymentOptions PaymentOptions

foodOrderErrors.error = "UNAVAILABLE_SLOT", "PROMO_EXPIRED", "PROMO_NOT_APPLICABLE", "PROMO_NOT_RECOGNIZED", "PROMO_ORDER_INELIGIBLE", "PROMO_USER_INELIGIBLE", "AVAILABILITY_CHANGED", "INCORRECT_PRICE", "INVALID", "NOT_FOUND", or "PRICE_CHANGED" 时是必需的。

用户选择的默认付款方式。

additionalPaymentOptions 列表<PaymentOptions>

用户可使用的备选付款方式。

以下示例展示了 FoodErrorExtension 元素:

示例

{
  "@type": "type.googleapis.com/google.actions.v2.orders.FoodErrorExtension",
  "foodOrderErrors": [
    {
      "error": "PRICE_CHANGED",
      "id": "sample_item_offer_id_1",
      "description": "The price has changed.",
      "updatedPrice": {
        "currencyCode": "USD",
        "units": "2",
        "nanos": 750000000
      }
    },
    {
      "error": "PRICE_CHANGED",
      "id": "sample_item_offer_id_2",
      "description": "The price has changed.",
      "updatedPrice": {
        "currencyCode": "USD",
        "units": "8"
      }
    }
  ],
  "correctedProposedOrder": {
    "id": "sample_corrected_proposed_order_id_1",
    "otherItems": [
      {
        "name": "New customer discount",
        "price": {
          "type": "ESTIMATE",
          "amount": {
            "currencyCode": "USD",
            "units": "-5",
            "nanos": -500000000
          }
        },
        "type": "DISCOUNT"
      },
      {
        "name": "Delivery fee",
        "price": {
          "type": "ESTIMATE",
          "amount": {
            "currencyCode": "USD",
            "units": "3",
            "nanos": 500000000
          }
        },
        "type": "DELIVERY"
      },
      {
        "name": "Tax",
        "price": {
          "type": "ESTIMATE",
          "amount": {
            "currencyCode": "USD",
            "units": "1",
            "nanos": 500000000
          }
        },
        "type": "TAX"
      }
    ],
    "cart": {
      "merchant": {
        "id": "https://www.exampleprovider.com/merchant/id1",
        "name": "Falafel Bite"
      },
      "lineItems": [
        {
          "name": "Pita Chips",
          "type": "REGULAR",
          "id": "sample_item_offer_id_1",
          "offerId": "https://www.exampleprovider.com/menu/item/offer/id1",
          "quantity": 1,
          "price": {
            "type": "ESTIMATE",
            "amount": {
              "currencyCode": "USD",
              "units": "2",
              "nanos": 750000000
            }
          },
          "subLines": [
            {
              "note": "Notes for this item."
            }
          ],
          "extension": {
            "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension",
            "options": [
              {
                "id": "sample_addon_offer_id_1",
                "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id1",
                "name": "Honey Mustard",
                "price": {
                  "currencyCode": "USD"
                },
                "quantity": 1
              },
              {
                "id": "sample_addon_offer_id_2",
                "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id2",
                "name": "BBQ Sauce",
                "price": {
                  "currencyCode": "USD",
                  "nanos": 500000000
                },
                "quantity": 1
              }
            ]
          }
        },
        {
          "name": "Chicken Shwarma Wrap",
          "type": "REGULAR",
          "id": "sample_item_offer_id_2",
          "offerId": "https://www.exampleprovider.com/menu/item/offer/id2",
          "quantity": 1,
          "price": {
            "type": "ESTIMATE",
            "amount": {
              "currencyCode": "USD",
              "units": "8"
            }
          },
          "extension": {
            "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension"
          }
        },
        {
          "name": "Greek Salad",
          "type": "REGULAR",
          "id": "sample_item_offer_id_3",
          "offerId": "https://www.exampleprovider.com/menu/item/offer/id3",
          "quantity": 1,
          "price": {
            "type": "ESTIMATE",
            "amount": {
              "currencyCode": "USD",
              "units": "9",
              "nanos": 990000000
            }
          },
          "extension": {
            "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension"
          }
        },
        {
          "name": "Prawns Biryani",
          "type": "REGULAR",
          "id": "sample_item_offer_id_4",
          "offerId": "https://www.exampleprovider.com/menu/item/offer/id4",
          "quantity": 1,
          "price": {
            "type": "ESTIMATE",
            "amount": {
              "currencyCode": "USD",
              "units": "15",
              "nanos": 990000000
            }
          },
          "extension": {
            "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension"
          }
        }
      ],
      "extension": {
        "@type": "type.googleapis.com/google.actions.v2.orders.FoodCartExtension",
        "fulfillmentPreference": {
          "fulfillmentInfo": {
            "delivery": {
              "deliveryTimeIso8601": "P90M"
            }
          }
        },
        "location": {
          "coordinates": {
            "latitude": 37.788783,
            "longitude": -122.41384
          },
          "formattedAddress": "1350 CHARLESTON ROAD, MOUNTAIN VIEW, CA, United States",
          "zipCode": "94043",
          "city": "Mountain View",
          "postalAddress": {
            "regionCode": "US",
            "postalCode": "94043",
            "administrativeArea": "CA",
            "locality": "Mountain View",
            "addressLines": [
              "1350 Charleston Road"
            ]
          },
          "notes": "Gate code is #111"
        }
      }
    },
    "totalPrice": {
      "type": "ESTIMATE",
      "amount": {
        "currencyCode": "USD",
        "units": "36",
        "nanos": 730000000
      }
    },
    "extension": {
      "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderExtension",
      "availableFulfillmentOptions": [
        {
          "fulfillmentInfo": {
            "delivery": {
              "deliveryTimeIso8601": "P90M"
            }
          },
          "expiresAt": "2017-07-17T12:30:00Z"
        }
      ]
    }
  },
  "paymentOptions": {
    "googleProvidedOptions": {
      "tokenizationParameters": {
        "tokenizationType": "PAYMENT_GATEWAY",
        "parameters": {
          "gateway": "stripe",
          "stripe:publishableKey": "pk_live_stripe_client_key",
          "stripe:version": "2017-04-06"
        }
      },
      "supportedCardNetworks": [
        "AMEX",
        "DISCOVER",
        "MASTERCARD",
        "JCB",
        "VISA"
      ],
      "prepaidCardDisallowed": true
    }
  }
}

FoodItemExtension

定义菜品的插件。

下表列出了 FoodItemExtension 类型的属性:

媒体资源 类型 说明
@type 对比度

必填。

此扩展程序的类型。此字段始终设置为“type.googleapis.com/google.actions.v2.orders.FoodItemExtension”。

值:type.googleapis.com/google.actions.v2.orders.FoodItemExtension

options 列表<FoodItemOption>

选项可以是插件项,也可以是包含一组插件的插件组。

以下示例展示了 FoodItemExtension 元素:

示例

{
  "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension",
  "options": [
    {
      "id": "sample_addon_offer_id_1",
      "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id1",
      "name": "Honey Mustard",
      "price": {
        "currencyCode": "USD"
      },
      "quantity": 1
    },
    {
      "id": "sample_addon_offer_id_2",
      "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id2",
      "name": "BBQ Sauce",
      "price": {
        "currencyCode": "USD",
        "nanos": 500000000
      },
      "quantity": 1,
      "subOptions": [
        {
          "id": "10239138",
          "offerId": "912391723",
          "name": "Fries",
          "price": {
            "currencyCode": "USD",
            "units": "2",
            "nanos": 230000000
          },
          "quantity": 1
        }
      ]
    }
  ]
}

FoodItemOption

下表列出了 FoodItemOption 类型的属性:

媒体资源 类型 说明
id String

由 Google 分配的唯一 ID。当您发送 FoodOrderError 或 AsyncOrderUpdateRequest 时,如果购物车中有多件商品具有相同的 OfferId,请使用此字段进行区分。

示例:39231093

offerId String

商品的优惠 ID。

示例:912835081

name String

选项名称。

示例:Honey Mustard

price Money
note String

与选项相关的备注。

quantity 编号

对于包含内容的选项,该值表示内容数量。

示例:3

subOptions 列表<FoodItemOption>

选项的子选项(如果有)。

示例:[ { "id": "71283712", "offerId": "51209121", "name": "BBQ Sauce", "price": { "currencyCode": "USD", "units": "3", "nanos": 780000000 }, "quantity": 2 }, { "id": "102941024", "offerId": "12084102", "name": "Ketchup", "price": { "currencyCode": "USD", "units": "2", "nanos": 980000000 }, "quantity": 6 } ]

以下示例展示了 FoodItemOption 元素:

示例 1

{
  "id": "10293231",
  "offerId": "1918491",
  "name": "Honey Mustard",
  "price": {
    "currencyCode": "USD",
    "units": "1",
    "nanos": 250000000
  },
  "quantity": 5
}

示例 2

{
  "id": "123166552",
  "offerId": "912849184",
  "name": "Make It A Meal",
  "price": {
    "currencyCode": "USD",
    "units": "3",
    "nanos": 730000000
  },
  "quantity": 1,
  "subOptions": [
    {
      "id": "10239138",
      "offerId": "912391723",
      "name": "Fries",
      "price": {
        "currencyCode": "USD",
        "units": "2",
        "nanos": 230000000
      },
      "quantity": 1
    },
    {
      "id": "57159183",
      "offerId": "81837123",
      "name": "Drink",
      "price": {
        "currencyCode": "USD",
        "units": "3",
        "nanos": 130000000
      },
      "quantity": 1
    }
  ]
}

FoodOrderError

CheckoutResponse 中包含有关错误的详细信息。

下表列出了 FoodOrderError 类型的属性:

媒体资源 类型 说明
error Error

必填。

id String

error = "AVAILABILITY_CHANGED", "INCORRECT_PRICE", "PRICE_CHANGED", "INVALID", or "NOT_FOUND" 时是必需的。

对于商品级错误,必须填写此字段。它是 Google 为菜单项分配的 LINE.id 或为插件分配的 FoodItemOption.id。

description String

错误说明。此说明仅供内部记录,不会向用户显示。

updatedPrice Money

error = "PRICE_CHANGED" 时是必需的。

导致错误的商品的新价格。仅当错误为“PRICE_CHANGED”时才需要此属性。

availableQuantity 整数

error = "INVALID", or "NOT_FOUND" 时是必需的。

导致错误的商品的新可售数量。仅当错误为“INVALID”或“NOT_FOUND”时,才需要此字段。“INVALID”和“NOT_FOUND”的值应为零。

以下示例展示了 FoodOrderError 元素:

示例 1

{
  "error": "CLOSED",
  "description": "This store is currently reachable. Please try again later."
}

示例 2

{
  "error": "PRICE_CHANGED",
  "id": "french_fries",
  "description": "The price has changed.",
  "updatedPrice": {
    "currencyCode": "USD",
    "units": "2",
    "nanos": 750000000
  }
}

FoodOrderExtension

包含订单的履单信息。

下表列出了 FoodOrderExtension 类型的属性:

媒体资源 类型 说明
@type 对比度

此扩展程序的类型。此字段始终设置为“type.googleapis.com/google.actions.v2.orders.FoodOrderExtension”。

值:type.googleapis.com/google.actions.v2.orders.FoodOrderExtension

availableFulfillmentOptions 列表<FulfillmentOption>

表示订单的可用履单选项。

optinForRemarketing Boolean

用户请求选择加入您的营销渠道。默认情况下,未经用户同意,您不得发送营销内容。如果 optinForRemarketing 为 true,则您可以订阅用户。如果 optinForRemarketing 为 false 或不存在,您必须在系统中按原样保留订阅状态。用户无法通过 Google 选择停用,只能通过您的营销渠道中提供的取消订阅功能来选择停用。此标志仅出现在 submitOrderRequestMessage 中。

以下示例展示了 FoodOrderExtension 元素:

示例 1

{
  "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderExtension",
  "availableFulfillmentOptions": [
    {
      "fulfillmentInfo": {
        "delivery": {
          "deliveryTimeIso8601": "P0M"
        }
      },
      "expiresAt": "2017-07-17T12:30:00Z"
    }
  ]
}

示例 2

{
  "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderExtension",
  "availableFulfillmentOptions": [
    {
      "fulfillmentInfo": {
        "pickup": {
          "pickupTimeIso8601": "P0M"
        }
      },
      "expiresAt": "2020-08-20T11:41:00Z"
    }
  ],
  "optinForRemarketing": true
}

FulfillmentOption

您可以通过以下方式使用 FulfillmentOption 对象:
  • Checkout AppRequestSubmit AppRequest 中,Cart.extension.fulfillmentPreference:存储用户的偏好设置(送餐或自提)。发送结账请求时,价格始终为 0。
  • Checkout AppResponse 中,ProposedOrder.extension.availableFulfillmentOptions:定义一个或多个传送选项(目前仅支持一个选项)。您可以在 ProposedOrder.otherItems 中将默认选项指定为 LineItemFulfillmentOptionofferId 应与 ProposedOrder.otherItems 中指定的 LineItem 的 ID 一致。

下表列出了 FulfillmentOption 类型的属性:

媒体资源 类型 说明
offerId String

此执行方式选项的唯一标识符(如果有)。

fulfillmentInfo FulfillmentOptionInfo

必填。

expiresAt ISO 时间戳

此履单选项的过期时间。

price Money

此选项的费用。

以下示例展示了 FulfillmentOption 元素:

示例

{
  "offerId": "offer5",
  "fulfillmentInfo": {
    "pickup": {
      "pickupTimeIso8601": "P0M"
    }
  },
  "expiresAt": "2019-05-02T00:00:00-07:00",
  "price": {
    "currencyCode": "USD",
    "units": "5",
    "nanos": 230000000
  }
}

FulfillmentOptionInfo

定义与 FulfillmentInfo 相关的信息。

下表列出了 FulfillmentOptionInfo 类型的属性:

媒体资源 类型 说明
以下属性组中只有以下一组属性:
delivery 分组 1 DeliveryInfo

如果存在,则表示投递订单。

pickup 分组 2 PickupInfo

如果存在,则表示自提订单。

图片

下表列出了 Image 类型的属性:

媒体资源 类型 说明
sourceUrl String

必填。

图片的网址。图片最小应为 72x72 像素。为获得最佳效果,请使用不低于 216x216 像素的图片。图片必须小于 6 MB 和 6400 万像素。

LineItem

定义购物车的内容 (Cart.lineItems) 或订单的额外费用 (ProposedOrder.otherItems)。

下表列出了 LineItem 类型的属性:

媒体资源 类型 说明
id String

type = "REGULAR" 时是必需的。

对于购物车中的订单项 (ProposedOrder.cart.lineItems[0].id),这是 Google 在创建订单时创建的唯一 ID。对于 ProposedOrder.otherItems[0].id(用于添加运费和税费等商品)中的 ProposedOrder 订单项,id 的值由提供商定义。例如,一个购物车中有两个相同的菜品,准备说明各有不同(例如两份中等的披萨,配料不同的一组)。在本例中,两件商品的基础优惠 ID 相同。当您发送订单更新请求以指示商品遭拒时,请使用此 ID 作为消除歧义。换句话说,如果其中一份披萨因缺少特定配料而被拒,此 ID 可帮助 Google 确定您提及的顺序中的哪个菜品。此字段是必填字段(otherItems 除外)。

name String

必填。

订单项的名称。这是一个用户可见的字符串,应尽可能采用句首字母大写形式(如“运费”、“服务费”、“税费”)。对于用户而言,此字段的长度不得超过 100 个字符。

type LineItemType

必填。

quantity 整数

type = "REGULAR" 时是必需的。

所含商品的数量。不适用于 ProposedOrder.otherItems。

description String

商品的说明。

price Price

必填。

商品的价格。此值反映的是此订单项中所有商品或服务的总价格(也就是说,将各个附加服务的费用相加后乘以数量)。例如:如果某件商品的数量是 10 美元,那么价格就是 30 美元。如果一份披萨的基本价格为 5 美元,外加附加费为 1 美元,那么价格为 6 美元。如果两份披萨(数量 = 2)的基本价格为 5 美元,每个披萨的附加费为 1 美元,则价格为 12 美元。每个订单项都应有一个价格,即使价格为“0”也是如此。当类型为 DISCOUNT 时,将值指定为负值(例如“-2”)。

subLines 列表<SublineNote>

可选,仅在类型为“REGULAR”时有效。系统可能会在结账请求和订单提交请求的此字段内发送用户针对商品的具体备注。确保商家在收到提供备注后会收到该通知。它将以 subLines[0].note 的形式出现在请求中,当该值出现在请求中时,它将是此字段提供的唯一值。

不得超过 1 项

offerId String

type = "REGULAR" 时是必需的。

商品的 MenuItem 的优惠 ID。不适用于 ProposedOrder.otherItems。

extension FoodItemExtension

定义菜品的插件。

以下示例展示了 LineItem 元素:

示例 1

{
  "name": "New customer discount",
  "price": {
    "type": "ESTIMATE",
    "amount": {
      "currencyCode": "USD",
      "units": "-5",
      "nanos": -500000000
    }
  },
  "type": "DISCOUNT"
}

示例 2

{
  "name": "Pita Chips",
  "type": "REGULAR",
  "id": "sample_item_offer_id_1",
  "offerId": "https://www.exampleprovider.com/menu/item/offer/id1",
  "quantity": 1,
  "price": {
    "type": "ESTIMATE",
    "amount": {
      "currencyCode": "USD",
      "units": "2",
      "nanos": 750000000
    }
  },
  "subLines": [
    {
      "note": "Notes for this item."
    }
  ],
  "extension": {
    "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension",
    "options": [
      {
        "id": "sample_addon_offer_id_1",
        "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id1",
        "name": "Honey Mustard",
        "price": {
          "currencyCode": "USD"
        },
        "quantity": 1
      },
      {
        "id": "sample_addon_offer_id_2",
        "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id2",
        "name": "BBQ Sauce",
        "price": {
          "currencyCode": "USD",
          "nanos": 500000000
        },
        "quantity": 1
      }
    ]
  }
}

LineItemType

LineItemType 类型具有以下可能的值:

  • REGULAR:商品订单项。适用于 Cart.lineItems。
  • TAX:税费订单项。适用于 ProposedOrder.otherItems。
  • DISCOUNT:折扣订单项。请注意,价格应为负数。适用于 ProposedOrder.otherItems。
  • GRATUITY:免费订单项。通常预留给用户选择的小费的 SubmitOrderRequestMessage。适用于 ProposedOrder.otherItems。
  • DELIVERY:投放订单项。适用于 ProposedOrder.otherItems。
  • SUBTOTAL:订单项小计。适用于 ProposedOrder.otherItems。
  • FEE:其他类型未涵盖的其他订单项。适用于 ProposedOrder.otherItems。

位置

指定订餐地址。Location 类型在 Cart 中仅用于表示配送订单的目的地。 如果用户下单,最终的地理位置也会在 TransactionDecisionValue 中显示。对于指定自提服务的订单,系统不会添加任何地点(即使是空地点也不例外)。

下表列出了 Location 类型的属性:

媒体资源 类型 说明
coordinates Coordinates
formattedAddress String

营业地点的显示地址。

示例:1350 CHARLESTON ROAD, MOUNTAIN VIEW, CA, United States

postalAddress PostalAddress
zipCode String

示例:90210

city String

城市的名称。

示例:Los Angeles

notes String

关于地点的备注,例如门牌号。名称长度不应超过 500 个字符。

示例:Gate code is #111

以下示例展示了 Location 元素:

示例

{
  "coordinates": {
    "latitude": 37.788783,
    "longitude": -122.41384
  },
  "formattedAddress": "1350 CHARLESTON ROAD, MOUNTAIN VIEW, CA, United States",
  "zipCode": "94043",
  "city": "Mountain View",
  "postalAddress": {
    "regionCode": "US",
    "postalCode": "94043",
    "administrativeArea": "CA",
    "locality": "Mountain View",
    "addressLines": [
      "1350 Charleston Road"
    ]
  },
  "notes": "Gate code is #111"
}

商家

下表列出了 Merchant 类型的属性:

媒体资源 类型 说明
id String

商家的 ID。如果指定,则与餐厅 Feed 中的 Restaurant.@id 匹配。

示例:https://www.exampleprovider.com/merchant/id1

name String

必填。

用户可见的商家名称。

示例:Falafel Bite

以下示例展示了 Merchant 元素:

示例

{
  "id": "https://www.exampleprovider.com/merchant/id1",
  "name": "Falafel Bite"
}

币种

下表列出了 Money 类型的属性:

媒体资源 类型 说明
currencyCode String

必填。

采用 ISO 4217 格式的 3 个字母货币代码。

示例:USD

units String

金额的整数单位。例如,如果 currencyCode 是“USD”,则“1”单位就是一美元。

示例:36

nanos 整数

金额的纳诺 (10^-9) 单位数。该值必须介于 -999999999(含)到 +999999999(含)之间。请使用以下规则:如果单位数是正数,纳诺必须是正数或零。如果单位数为零,纳诺可以是正数、零或负数。如果单位数是负数,纳诺必须是负数或零。例如 $-1.75 表示为单位 = -1 和 nanos = -750,000,000。

示例:730000000

以下示例展示了 Money 元素:

示例 1

{
  "currencyCode": "USD",
  "units": "36",
  "nanos": 730000000
}

示例 2

{
  "currencyCode": "EUR",
  "units": "10"
}

下单

包含最终订单,包括税费、费用、运费以及付款信息。您的操作会在 Submit AppRequest 中接收此对象。

下表列出了 Order 类型的属性:

媒体资源 类型 说明
finalOrder ProposedOrder

必填。

促成订单的建议订单。

googleOrderId String

必填。

由 Google 分配的订单 ID。此 ID 应在订单的整个生命周期内保持不变。此 ID 不会向最终用户显示。

orderDate ISO 时间戳

必填。

订单的创建日期和时间。

paymentInfo PaymentInfo

必填。

与此订单的付款相对应的付款信息。

以下示例展示了 Order 元素:

示例

{
  "finalOrder": {
    "cart": {
      "notes": "Guest prefers their food to be hot when it is delivered.",
      "merchant": {
        "id": "https://www.exampleprovider.com/merchant/id1",
        "name": "Cucina Venti"
      },
      "lineItems": [
        {
          "name": "Sizzling Prawns Dinner",
          "type": "REGULAR",
          "id": "sample_item_offer_id_1",
          "offerId": "https://www.exampleprovider.com/menu/item/offer/id1",
          "quantity": 1,
          "price": {
            "type": "ESTIMATE",
            "amount": {
              "currencyCode": "USD",
              "units": "16",
              "nanos": 750000000
            }
          },
          "subLines": [
            {
              "note": "Notes for this item."
            }
          ],
          "extension": {
            "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension",
            "options": [
              {
                "id": "sample_addon_offer_id_1",
                "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id1",
                "name": "Honey Mustard",
                "price": {
                  "currencyCode": "USD"
                },
                "quantity": 1
              },
              {
                "id": "sample_addon_offer_id_2",
                "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id2",
                "name": "BBQ Sauce",
                "price": {
                  "currencyCode": "USD",
                  "nanos": 500000000
                },
                "quantity": 1
              }
            ]
          }
        }
      ],
      "extension": {
        "@type": "type.googleapis.com/google.actions.v2.orders.FoodCartExtension",
        "fulfillmentPreference": {
          "fulfillmentInfo": {
            "pickup": {
              "pickupTimeIso8601": "P0M"
            }
          }
        },
        "contact": {
          "displayName": "Lovefood Ordering",
          "email": "ilovefood@example.com",
          "phoneNumber": "+16501234567"
        }
      }
    },
    "otherItems": [
      {
        "name": "Service fee",
        "type": "FEE",
        "price": {
          "type": "ESTIMATE",
          "amount": {
            "currencyCode": "USD",
            "units": "3",
            "nanos": 500000000
          }
        }
      },
      {
        "name": "Tax",
        "type": "TAX",
        "price": {
          "type": "ESTIMATE",
          "amount": {
            "currencyCode": "USD",
            "units": "1",
            "nanos": 370000000
          }
        }
      },
      {
        "name": "Tip",
        "type": "GRATUITY",
        "price": {
          "type": "ESTIMATE",
          "amount": {
            "currencyCode": "USD",
            "units": "2",
            "nanos": 590000000
          }
        }
      }
    ],
    "totalPrice": {
      "type": "ESTIMATE",
      "amount": {
        "currencyCode": "USD",
        "units": "23",
        "nanos": 710000000
      }
    },
    "id": "sample_final_order_id",
    "extension": {
      "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderExtension",
      "availableFulfillmentOptions": [
        {
          "fulfillmentInfo": {
            "pickup": {
              "pickupTimeIso8601": "P0M"
            }
          },
          "expiresAt": "2017-07-17T12:30:00Z"
        }
      ],
      "optinForRemarketing": true
    }
  },
  "googleOrderId": "sample_google_order_id",
  "orderDate": "2017-07-17T12:00:00Z",
  "paymentInfo": {
    "displayName": "Visa\u2006****\u20061111",
    "googleProvidedPaymentInstrument": {
      "instrumentToken": "abcd"
    },
    "paymentType": "PAYMENT_CARD"
  }
}

OrderUpdate

下表列出了 AppResponse 中包含的 OrderUpdate 类型的字段。

下表列出了 OrderUpdate 类型的属性:

媒体资源 类型 说明
actionOrderId String

必填。

集成商系统中的订单的唯一 ID,用于标识发送更新的顺序。如果未在“CREATED”订单的 OrderUpdate 中至少提供一次 received.user_visible_order_id,则此 ID 将是输入的用户可见 ID,显示在 Google 订单卡片中。

orderState OrderState

必填。

订单的新状态。

lineItemUpdates Map<String, LineItemUpdate>
updateTime ISO 时间戳

必填。

订单更新时间。

orderManagementActions 列表<OrderManagementAction>

下单后执行的操作,例如与支持团队联系和查看订单详情。

不得少于 1 项,也不得超过 6 项

rejectionInfo RejectionInfo

orderState.state = "REJECTED" 时是必需的。

cancellationInfo CancellationInfo

orderState.state = "CANCELLED" 时是必需的。

inTransitInfo InTransitInfo

此字段已弃用。

fulfillmentInfo FulfillmentInfo

此字段已弃用。

receipt Receipt

orderState.state = "CONFIRMED", "IN_PREPARATION", or "READY_FOR_PICKUP" 时是必需的。

在收据中提供用户可见的订单 ID。

totalPrice Price

订单总价。

infoExtension FoodOrderUpdateExtension

指定订单更新的更多详情,例如预计送达或自提的时间间隔。

以下示例展示了 OrderUpdate 元素:

示例

{
  "actionOrderId": "sample_action_order_id",
  "orderState": {
    "state": "CONFIRMED",
    "label": "Provider confirmed"
  },
  "totalPrice": {
    "type": "ESTIMATE",
    "amount": {
      "currencyCode": "USD",
      "units": "41",
      "nanos": 600000000
    }
  },
  "lineItemUpdates": {
    "sample_item_id_1": {
      "price": {
        "type": "ESTIMATE",
        "amount": {
          "currencyCode": "USD",
          "units": "3",
          "nanos": 500000000
        }
      },
      "reason": "This item has an updated price."
    }
  },
  "receipt": {
    "userVisibleOrderId": "userVisibleId1234"
  },
  "updateTime": "2017-07-17T12:00:00Z",
  "orderManagementActions": [
    {
      "type": "CUSTOMER_SERVICE",
      "button": {
        "title": "Contact customer service",
        "openUrlAction": {
          "url": "mailto:support@example.com"
        }
      }
    },
    {
      "type": "EMAIL",
      "button": {
        "title": "Email restaurant",
        "openUrlAction": {
          "url": "mailto:person@example.com"
        }
      }
    },
    {
      "type": "CALL_RESTAURANT",
      "button": {
        "title": "Call restaurant",
        "openUrlAction": {
          "url": "tel:+16505554679"
        }
      }
    }
  ],
  "infoExtension": {
    "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension",
    "estimatedFulfillmentTimeIso8601": "2017-07-17T13:00:00Z/2017-07-17T13:30:00Z"
  }
}

PickupInfo

下表列出了 PickupInfo 类型的属性:

媒体资源 类型 说明
pickupTimeIso8601 String

预计取货时间,采用 ISO 8601 时间戳格式:{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z”,或时长格式:“P(n)Y(n)M(n)DT(n)H(n)M(n)S”。例如,PT90M 表示时长 90 分钟。默认值“PT0M”表示首选自取时间越短。参考文档:https://zh.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations。使用此方法可在结账响应期间更新预计自提时间。

示例:PT90M

以下示例展示了 PickupInfo 元素:

示例

{
  "pickupTimeIso8601": "PT90M"
}

PostalAddress

下表列出了 PostalAddress 类型的属性:

媒体资源 类型 说明
regionCode String

必填。

两个字母的国家/地区代码。

示例:US

postalCode String

邮政编码。

示例:94043

administrativeArea String

最高行政区划,用于国家或地区的邮政地址。这可以是州、省、州或县。

示例:CA

locality String

此位置所在的城市或城镇。对于没有明确定义市行政区或者其无法融入此结构的地区,请勿指定市行政区,而改用 addressLines 字段。

示例:Mountain View

addressLines List<String>

用于指定街道地址的一行或多行。请勿修改此字段,因为它可能包含不明确的市行政区。

示例:[ "1350 Charleston Road" ]

recipients List<String>

订单的收货人列表。此字段仅在 billingAddress 中可用。

以下示例展示了 PostalAddress 元素:

示例

{
  "regionCode": "US",
  "postalCode": "94043",
  "administrativeArea": "CA",
  "locality": "Mountain View",
  "addressLines": [
    "1350 Charleston Road"
  ]
}

Price

下表列出了 Price 类型的属性:

媒体资源 类型 说明
type Enum [ "ESTIMATE", "ACTUAL" ]

必填。

促销优惠券代码。

amount Money

必填。

促销

下表列出了 Promotion 类型的属性:

媒体资源 类型 说明
coupon String

必填。

促销优惠券代码。

ProposedOrder

下表列出了 ProposedOrder 类型的属性:

媒体资源 类型 说明
id String

所提议订单的可选 ID。

cart Cart

必填。

用户的项目。

otherItems 列表<LineItem>

提供商添加的商品,例如运费、其他费用和税费。其他商品也可能包含用户添加的小费和/或折扣。

不得超过 10 项

image Image

与提议的订单相关联的图片。

totalPrice Price

必填。

提议的订单的总价。

extension FoodOrderExtension

必填。

定义食品订单的履单信息。

disclaimers 列表<Disclaimer>

对应于下单前在界面中显示的免责声明消息。

以下示例展示了 ProposedOrder 元素:

示例

{
  "id": "sample_proposed_order_id_1",
  "otherItems": [
    {
      "name": "New customer discount",
      "price": {
        "type": "ESTIMATE",
        "amount": {
          "currencyCode": "USD",
          "units": "-5",
          "nanos": -500000000
        }
      },
      "type": "DISCOUNT"
    },
    {
      "name": "Delivery fee",
      "price": {
        "type": "ESTIMATE",
        "amount": {
          "currencyCode": "USD",
          "units": "3",
          "nanos": 500000000
        }
      },
      "type": "DELIVERY"
    },
    {
      "name": "Tax",
      "price": {
        "type": "ESTIMATE",
        "amount": {
          "currencyCode": "USD",
          "units": "1",
          "nanos": 500000000
        }
      },
      "type": "TAX"
    }
  ],
  "cart": {
    "merchant": {
      "id": "https://www.exampleprovider.com/merchant/id1",
      "name": "Falafel Bite"
    },
    "lineItems": [
      {
        "name": "Pita Chips",
        "type": "REGULAR",
        "id": "sample_item_offer_id_1",
        "offerId": "https://www.exampleprovider.com/menu/item/offer/id1",
        "quantity": 1,
        "price": {
          "type": "ESTIMATE",
          "amount": {
            "currencyCode": "USD",
            "units": "2",
            "nanos": 750000000
          }
        },
        "subLines": [
          {
            "note": "Notes for this item."
          }
        ],
        "extension": {
          "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension",
          "options": [
            {
              "id": "sample_addon_offer_id_1",
              "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id1",
              "name": "Honey Mustard",
              "price": {
                "currencyCode": "USD"
              },
              "quantity": 1
            },
            {
              "id": "sample_addon_offer_id_2",
              "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id2",
              "name": "BBQ Sauce",
              "price": {
                "currencyCode": "USD",
                "nanos": 500000000
              },
              "quantity": 1
            }
          ]
        }
      },
      {
        "name": "Chicken Shwarma Wrap",
        "type": "REGULAR",
        "id": "sample_item_offer_id_2",
        "offerId": "https://www.exampleprovider.com/menu/item/offer/id2",
        "quantity": 1,
        "price": {
          "type": "ESTIMATE",
          "amount": {
            "currencyCode": "USD",
            "units": "8"
          }
        },
        "extension": {
          "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension"
        }
      },
      {
        "name": "Greek Salad",
        "type": "REGULAR",
        "id": "sample_item_offer_id_3",
        "offerId": "https://www.exampleprovider.com/menu/item/offer/id3",
        "quantity": 1,
        "price": {
          "type": "ESTIMATE",
          "amount": {
            "currencyCode": "USD",
            "units": "9",
            "nanos": 990000000
          }
        },
        "extension": {
          "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension"
        }
      },
      {
        "name": "Prawns Biryani",
        "type": "REGULAR",
        "id": "sample_item_offer_id_4",
        "offerId": "https://www.exampleprovider.com/menu/item/offer/id4",
        "quantity": 1,
        "price": {
          "type": "ESTIMATE",
          "amount": {
            "currencyCode": "USD",
            "units": "15",
            "nanos": 990000000
          }
        },
        "extension": {
          "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension"
        }
      }
    ],
    "extension": {
      "@type": "type.googleapis.com/google.actions.v2.orders.FoodCartExtension",
      "fulfillmentPreference": {
        "fulfillmentInfo": {
          "delivery": {
            "deliveryTimeIso8601": "P90M"
          }
        }
      },
      "location": {
        "coordinates": {
          "latitude": 37.788783,
          "longitude": -122.41384
        },
        "formattedAddress": "1350 CHARLESTON ROAD, MOUNTAIN VIEW, CA, United States",
        "zipCode": "94043",
        "city": "Mountain View",
        "postalAddress": {
          "regionCode": "US",
          "postalCode": "94043",
          "administrativeArea": "CA",
          "locality": "Mountain View",
          "addressLines": [
            "1350 Charleston Road"
          ]
        },
        "notes": "Gate code is #111"
      }
    }
  },
  "totalPrice": {
    "type": "ESTIMATE",
    "amount": {
      "currencyCode": "USD",
      "units": "36",
      "nanos": 730000000
    }
  },
  "extension": {
    "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderExtension",
    "availableFulfillmentOptions": [
      {
        "fulfillmentInfo": {
          "delivery": {
            "deliveryTimeIso8601": "P0M"
          }
        },
        "expiresAt": "2017-07-17T12:30:00Z"
      }
    ]
  }
}

SublineNote

下表列出了 SublineNote 类型的属性:

媒体资源 类型 说明
note String

必填。

时间戳

日期和时间,采用以下格式: "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"

TransactionDecisionValue

包含 Order

下表列出了 TransactionDecisionValue 类型的属性:

媒体资源 类型 说明
order Order

必填。

下单时将会显示付款信息。

以下示例展示了 TransactionDecisionValue 元素:

示例

{
  "order": {
    "finalOrder": {
      "cart": {
        "notes": "Guest prefers their food to be hot when it is delivered.",
        "merchant": {
          "id": "https://www.exampleprovider.com/merchant/id1",
          "name": "Cucina Venti"
        },
        "lineItems": [
          {
            "name": "Sizzling Prawns Dinner",
            "type": "REGULAR",
            "id": "sample_item_offer_id_1",
            "offerId": "https://www.exampleprovider.com/menu/item/offer/id1",
            "quantity": 1,
            "price": {
              "type": "ESTIMATE",
              "amount": {
                "currencyCode": "USD",
                "units": "16",
                "nanos": 750000000
              }
            },
            "subLines": [
              {
                "note": "Notes for this item."
              }
            ],
            "extension": {
              "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension",
              "options": [
                {
                  "id": "sample_addon_offer_id_1",
                  "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id1",
                  "name": "Honey Mustard",
                  "price": {
                    "currencyCode": "USD"
                  },
                  "quantity": 1
                },
                {
                  "id": "sample_addon_offer_id_2",
                  "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id2",
                  "name": "BBQ Sauce",
                  "price": {
                    "currencyCode": "USD",
                    "nanos": 500000000
                  },
                  "quantity": 1
                }
              ]
            }
          }
        ],
        "extension": {
          "@type": "type.googleapis.com/google.actions.v2.orders.FoodCartExtension",
          "fulfillmentPreference": {
            "fulfillmentInfo": {
              "pickup": {
                "pickupTimeIso8601": "P0M"
              }
            }
          },
          "contact": {
            "displayName": "Lovefood Ordering",
            "email": "ilovefood@example.com",
            "phoneNumber": "+16501234567"
          }
        }
      },
      "otherItems": [
        {
          "name": "Service fee",
          "type": "FEE",
          "price": {
            "type": "ESTIMATE",
            "amount": {
              "currencyCode": "USD",
              "units": "3",
              "nanos": 500000000
            }
          }
        },
        {
          "name": "Tax",
          "type": "TAX",
          "price": {
            "type": "ESTIMATE",
            "amount": {
              "currencyCode": "USD",
              "units": "1",
              "nanos": 370000000
            }
          }
        },
        {
          "name": "Tip",
          "type": "GRATUITY",
          "price": {
            "type": "ESTIMATE",
            "amount": {
              "currencyCode": "USD",
              "units": "2",
              "nanos": 590000000
            }
          }
        }
      ],
      "totalPrice": {
        "type": "ESTIMATE",
        "amount": {
          "currencyCode": "USD",
          "units": "23",
          "nanos": 710000000
        }
      },
      "id": "sample_final_order_id",
      "extension": {
        "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderExtension",
        "availableFulfillmentOptions": [
          {
            "fulfillmentInfo": {
              "pickup": {
                "pickupTimeIso8601": "P0M"
              }
            },
            "expiresAt": "2017-07-17T12:30:00Z"
          }
        ],
        "optinForRemarketing": true
      }
    },
    "googleOrderId": "sample_google_order_id",
    "orderDate": "2017-07-17T12:00:00Z",
    "paymentInfo": {
      "displayName": "Visa\u2006****\u20061111",
      "googleProvidedPaymentInstrument": {
        "instrumentToken": "abcd"
      },
      "paymentType": "PAYMENT_CARD"
    }
  }
}

履单请求

AppRequest

下表列出了 AppRequest 类型的属性:

媒体资源 类型 说明
isInSandbox Boolean

指明后续交易是否是在沙盒环境中完成。

conversation Conversation
inputs 列表<Input>

必填。

包含结账购物车的预期参数。

必须正好有 1 项

以下示例展示了 AppRequest 元素:

示例 1

{
  "isInSandbox": true,
  "inputs": [
    {
      "intent": "actions.foodordering.intent.CHECKOUT",
      "arguments": [
        {
          "extension": {
            "@type": "type.googleapis.com/google.actions.v2.orders.Cart",
            "merchant": {
              "id": "https://www.exampleprovider.com/merchant/id1",
              "name": "Cucina Venti"
            },
            "lineItems": [
              {
                "name": "Sizzling Prawns Dinner",
                "type": "REGULAR",
                "id": "sample_item_offer_id_1",
                "offerId": "https://www.exampleprovider.com/menu/item/offer/id1",
                "quantity": 1,
                "price": {
                  "type": "ESTIMATE",
                  "amount": {
                    "currencyCode": "USD",
                    "units": "16",
                    "nanos": 750000000
                  }
                },
                "subLines": [
                  {
                    "note": "Notes for this item."
                  }
                ],
                "extension": {
                  "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension",
                  "options": [
                    {
                      "id": "sample_addon_offer_id_1",
                      "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id1",
                      "name": "Honey Mustard",
                      "price": {
                        "currencyCode": "USD"
                      },
                      "quantity": 1
                    },
                    {
                      "id": "sample_addon_offer_id_2",
                      "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id2",
                      "name": "BBQ Sauce",
                      "price": {
                        "currencyCode": "USD",
                        "nanos": 500000000
                      },
                      "quantity": 1
                    }
                  ]
                }
              }
            ],
            "extension": {
              "@type": "type.googleapis.com/google.actions.v2.orders.FoodCartExtension",
              "fulfillmentPreference": {
                "fulfillmentInfo": {
                  "delivery": {
                    "deliveryTimeIso8601": "P0M"
                  }
                }
              },
              "location": {
                "coordinates": {
                  "latitude": 37.788783,
                  "longitude": -122.41384
                },
                "formattedAddress": "1350 CHARLESTON ROAD, MOUNTAIN VIEW, CA, United States",
                "zipCode": "94043",
                "city": "Mountain View",
                "postalAddress": {
                  "regionCode": "US",
                  "postalCode": "94043",
                  "administrativeArea": "CA",
                  "locality": "Mountain View",
                  "addressLines": [
                    "1350 Charleston Road"
                  ]
                },
                "notes": "Gate code is #111"
              }
            }
          }
        }
      ]
    }
  ]
}

示例 2

{
  "isInSandbox": true,
  "inputs": [
    {
      "intent": "actions.intent.TRANSACTION_DECISION",
      "arguments": [
        {
          "transactionDecisionValue": {
            "order": {
              "finalOrder": {
                "cart": {
                  "notes": "Guest prefers their food to be hot when it is delivered.",
                  "merchant": {
                    "id": "https://www.exampleprovider.com/merchant/id1",
                    "name": "Cucina Venti"
                  },
                  "lineItems": [
                    {
                      "name": "Sizzling Prawns Dinner",
                      "type": "REGULAR",
                      "id": "sample_item_offer_id_1",
                      "offerId": "https://www.exampleprovider.com/menu/item/offer/id1",
                      "quantity": 1,
                      "price": {
                        "type": "ESTIMATE",
                        "amount": {
                          "currencyCode": "USD",
                          "units": "16",
                          "nanos": 750000000
                        }
                      },
                      "subLines": [
                        {
                          "note": "Notes for this item."
                        }
                      ],
                      "extension": {
                        "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension",
                        "options": [
                          {
                            "id": "sample_addon_offer_id_1",
                            "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id1",
                            "name": "Honey Mustard",
                            "price": {
                              "currencyCode": "USD"
                            },
                            "quantity": 1
                          },
                          {
                            "id": "sample_addon_offer_id_2",
                            "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id2",
                            "name": "BBQ Sauce",
                            "price": {
                              "currencyCode": "USD",
                              "nanos": 500000000
                            },
                            "quantity": 1
                          }
                        ]
                      }
                    }
                  ],
                  "extension": {
                    "@type": "type.googleapis.com/google.actions.v2.orders.FoodCartExtension",
                    "fulfillmentPreference": {
                      "fulfillmentInfo": {
                        "pickup": {
                          "pickupTimeIso8601": "P0M"
                        }
                      }
                    },
                    "contact": {
                      "displayName": "Lovefood Ordering",
                      "email": "ilovefood@example.com",
                      "phoneNumber": "+16501234567"
                    }
                  }
                },
                "otherItems": [
                  {
                    "name": "Service fee",
                    "type": "FEE",
                    "price": {
                      "type": "ESTIMATE",
                      "amount": {
                        "currencyCode": "USD",
                        "units": "3",
                        "nanos": 500000000
                      }
                    }
                  },
                  {
                    "name": "Tax",
                    "type": "TAX",
                    "price": {
                      "type": "ESTIMATE",
                      "amount": {
                        "currencyCode": "USD",
                        "units": "1",
                        "nanos": 370000000
                      }
                    }
                  },
                  {
                    "name": "Tip",
                    "type": "GRATUITY",
                    "price": {
                      "type": "ESTIMATE",
                      "amount": {
                        "currencyCode": "USD",
                        "units": "2",
                        "nanos": 590000000
                      }
                    }
                  }
                ],
                "totalPrice": {
                  "type": "ESTIMATE",
                  "amount": {
                    "currencyCode": "USD",
                    "units": "23",
                    "nanos": 710000000
                  }
                },
                "id": "sample_final_order_id",
                "extension": {
                  "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderExtension",
                  "availableFulfillmentOptions": [
                    {
                      "fulfillmentInfo": {
                        "pickup": {
                          "pickupTimeIso8601": "P0M"
                        }
                      },
                      "expiresAt": "2017-07-17T12:30:00Z"
                    }
                  ],
                  "optinForRemarketing": true
                }
              },
              "googleOrderId": "sample_google_order_id",
              "orderDate": "2017-07-17T12:00:00Z",
              "paymentInfo": {
                "displayName": "Visa\u2006****\u20061111",
                "googleProvidedPaymentInstrument": {
                  "instrumentToken": "abcd"
                },
                "paymentType": "PAYMENT_CARD"
              }
            }
          }
        }
      ]
    }
  ]
}

CheckoutRequestMessage

CheckoutRequestMessage 是具有 actions.foodordering.intent.CHECKOUT intent 的 AppRequest

SubmitOrderRequestMessage

SubmitOrderRequestMessage 是具有 actions.foodordering.intent.TRANSACTION_DECISION intent 的 AppRequest

对话

Conversation 仅在一个会话中是唯一的。如果需要,您可以使用它将多个 CheckoutSubmitOrder 操作关联到一起。

下表列出了 Conversation 类型的属性:

媒体资源 类型 说明
conversationId String

必填。

对话的唯一 ID。

以下示例展示了 Conversation 元素:

示例

{
  "conversationId": "CQnJ7Z4i7UmvEZ9ph3AxyZRJ"
}

输入

对购物车结账的预期参数。

下表列出了 Input 类型的属性:

媒体资源 类型 说明
intent Enum [ "actions.foodordering.intent.CHECKOUT", "actions.intent.TRANSACTION_DECISION" ]

必填。

设置为“actions.foodordering.intent.CHECKOUT”(对于结账请求消息)或“actions.intent.TRANSACTION_DECISION”(对于提交订单请求消息)。

arguments 列表<Argument>

必填。

包含要结账或要下单的购物车

必须正好有 1 项

参数名

包含有关用户想要结账的菜品的详细信息。对于结账流程,仅可使用延期。对于提交订单,只有 transactionDecisionValue 是适用的

下表列出了 Argument 类型的属性:

媒体资源 类型 说明
以下属性组中只有以下一组属性:
extension 分组 1 Cart

详细说明用户想要结账的菜品。

transactionDecisionValue 分组 2 TransactionDecisionValue

包含要下单的订单以及付款信息。

履单响应

AppResponse

下表列出了 AppResponse 类型的属性:

媒体资源 类型 说明
expectUserResponse 对比度

设为 false。

值:False

finalResponse FinalResponse

必填。

包含您对购物车结账的响应。

以下示例展示了 AppResponse 元素:

示例 1

{
  "expectUserResponse": false,
  "finalResponse": {
    "richResponse": {
      "items": [
        {
          "structuredResponse": {
            "checkoutResponse": {
              "proposedOrder": {
                "id": "sample_proposed_order_id_1",
                "otherItems": [
                  {
                    "name": "New customer discount",
                    "price": {
                      "type": "ESTIMATE",
                      "amount": {
                        "currencyCode": "USD",
                        "units": "-5",
                        "nanos": -500000000
                      }
                    },
                    "type": "DISCOUNT"
                  },
                  {
                    "name": "Delivery fee",
                    "price": {
                      "type": "ESTIMATE",
                      "amount": {
                        "currencyCode": "USD",
                        "units": "3",
                        "nanos": 500000000
                      }
                    },
                    "type": "DELIVERY"
                  },
                  {
                    "name": "Tax",
                    "price": {
                      "type": "ESTIMATE",
                      "amount": {
                        "currencyCode": "USD",
                        "units": "1",
                        "nanos": 500000000
                      }
                    },
                    "type": "TAX"
                  }
                ],
                "cart": {
                  "merchant": {
                    "id": "https://www.exampleprovider.com/merchant/id1",
                    "name": "Falafel Bite"
                  },
                  "lineItems": [
                    {
                      "name": "Pita Chips",
                      "type": "REGULAR",
                      "id": "sample_item_offer_id_1",
                      "offerId": "https://www.exampleprovider.com/menu/item/offer/id1",
                      "quantity": 1,
                      "price": {
                        "type": "ESTIMATE",
                        "amount": {
                          "currencyCode": "USD",
                          "units": "2",
                          "nanos": 750000000
                        }
                      },
                      "subLines": [
                        {
                          "note": "Notes for this item."
                        }
                      ],
                      "extension": {
                        "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension",
                        "options": [
                          {
                            "id": "sample_addon_offer_id_1",
                            "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id1",
                            "name": "Honey Mustard",
                            "price": {
                              "currencyCode": "USD"
                            },
                            "quantity": 1
                          },
                          {
                            "id": "sample_addon_offer_id_2",
                            "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id2",
                            "name": "BBQ Sauce",
                            "price": {
                              "currencyCode": "USD",
                              "nanos": 500000000
                            },
                            "quantity": 1
                          }
                        ]
                      }
                    },
                    {
                      "name": "Chicken Shwarma Wrap",
                      "type": "REGULAR",
                      "id": "sample_item_offer_id_2",
                      "offerId": "https://www.exampleprovider.com/menu/item/offer/id2",
                      "quantity": 1,
                      "price": {
                        "type": "ESTIMATE",
                        "amount": {
                          "currencyCode": "USD",
                          "units": "8"
                        }
                      },
                      "extension": {
                        "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension"
                      }
                    },
                    {
                      "name": "Greek Salad",
                      "type": "REGULAR",
                      "id": "sample_item_offer_id_3",
                      "offerId": "https://www.exampleprovider.com/menu/item/offer/id3",
                      "quantity": 1,
                      "price": {
                        "type": "ESTIMATE",
                        "amount": {
                          "currencyCode": "USD",
                          "units": "9",
                          "nanos": 990000000
                        }
                      },
                      "extension": {
                        "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension"
                      }
                    },
                    {
                      "name": "Prawns Biryani",
                      "type": "REGULAR",
                      "id": "sample_item_offer_id_4",
                      "offerId": "https://www.exampleprovider.com/menu/item/offer/id4",
                      "quantity": 1,
                      "price": {
                        "type": "ESTIMATE",
                        "amount": {
                          "currencyCode": "USD",
                          "units": "15",
                          "nanos": 990000000
                        }
                      },
                      "extension": {
                        "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension"
                      }
                    }
                  ],
                  "extension": {
                    "@type": "type.googleapis.com/google.actions.v2.orders.FoodCartExtension",
                    "fulfillmentPreference": {
                      "fulfillmentInfo": {
                        "delivery": {
                          "deliveryTimeIso8601": "P90M"
                        }
                      }
                    },
                    "location": {
                      "coordinates": {
                        "latitude": 37.788783,
                        "longitude": -122.41384
                      },
                      "formattedAddress": "1350 CHARLESTON ROAD, MOUNTAIN VIEW, CA, United States",
                      "zipCode": "94043",
                      "city": "Mountain View",
                      "postalAddress": {
                        "regionCode": "US",
                        "postalCode": "94043",
                        "administrativeArea": "CA",
                        "locality": "Mountain View",
                        "addressLines": [
                          "1350 Charleston Road"
                        ]
                      },
                      "notes": "Gate code is #111"
                    }
                  }
                },
                "totalPrice": {
                  "type": "ESTIMATE",
                  "amount": {
                    "currencyCode": "USD",
                    "units": "36",
                    "nanos": 730000000
                  }
                },
                "extension": {
                  "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderExtension",
                  "availableFulfillmentOptions": [
                    {
                      "fulfillmentInfo": {
                        "delivery": {
                          "deliveryTimeIso8601": "P0M"
                        }
                      },
                      "expiresAt": "2017-07-17T12:30:00Z"
                    }
                  ]
                }
              },
              "paymentOptions": {
                "googleProvidedOptions": {
                  "facilitationSpecification": "{\"apiVersion\": 2,\"apiVersionMinor\": 0,\"merchantInfo\": {  \"merchantId\": \"Merchant ID\",  \"merchantName\": \"Merchant Name\"},\"allowedPaymentMethods\": [  {    \"type\": \"CARD\",    \"parameters\": {      \"allowedAuthMethods\": [        \"PAN_ONLY\"      ],      \"allowedCardNetworks\": [        \"VISA\",        \"AMEX\",        \"MASTERCARD\"      ],      \"billingAddressRequired\": false    },    \"tokenizationSpecification\": {      \"type\": \"PAYMENT_GATEWAY\",      \"parameters\": {        \"stripe:publishableKey\": \"pk_test_OoPcJNnxI1rDXhBq8BiXO2wz00s1Xc92dA\",        \"gateway\": \"stripe\",        \"stripe:version\": \"2019-05-16\"      }    }  }],\"transactionInfo\": {  \"currencyCode\": \"AUD\",  \"totalPriceStatus\": \"ESTIMATED\",  \"totalPrice\": \"1.0\"}}"
                }
              },
              "additionalPaymentOptions": [
                {
                  "actionProvidedOptions": {
                    "paymentType": "ON_FULFILLMENT",
                    "displayName": "Cash on delivery."
                  }
                }
              ]
            }
          }
        }
      ]
    }
  }
}

示例 2

{
  "expectUserResponse": false,
  "finalResponse": {
    "richResponse": {
      "items": [
        {
          "structuredResponse": {
            "orderUpdate": {
              "actionOrderId": "sample_action_order_id",
              "orderState": {
                "state": "CONFIRMED",
                "label": "Provider confirmed"
              },
              "receipt": {
                "userVisibleOrderId": "userVisibleId1234"
              },
              "updateTime": "2017-07-17T12:00:00Z",
              "orderManagementActions": [
                {
                  "type": "CUSTOMER_SERVICE",
                  "button": {
                    "title": "Contact customer service",
                    "openUrlAction": {
                      "url": "mailto:support@example.com"
                    }
                  }
                },
                {
                  "type": "CUSTOMER_SERVICE",
                  "button": {
                    "title": "Call customer service",
                    "openUrlAction": {
                      "url": "tel:+18005554679"
                    }
                  }
                },
                {
                  "type": "EMAIL",
                  "button": {
                    "title": "Email restaurant",
                    "openUrlAction": {
                      "url": "mailto:person@example.com"
                    }
                  }
                },
                {
                  "type": "CALL_RESTAURANT",
                  "button": {
                    "title": "Call restaurant",
                    "openUrlAction": {
                      "url": "tel:+16505554679"
                    }
                  }
                }
              ],
              "infoExtension": {
                "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension",
                "estimatedFulfillmentTimeIso8601": "2017-07-17T13:00:00Z/2017-07-17T13:30:00Z"
              }
            }
          }
        }
      ]
    }
  }
}

示例 3

{
  "expectUserResponse": false,
  "finalResponse": {
    "richResponse": {
      "items": [
        {
          "structuredResponse": {
            "error": {
              "@type": "type.googleapis.com/google.actions.v2.orders.FoodErrorExtension",
              "foodOrderErrors": [
                {
                  "error": "CLOSED",
                  "description": "The restaurant is closed."
                }
              ]
            }
          }
        }
      ]
    }
  }
}

示例 4

{
  "expectUserResponse": false,
  "finalResponse": {
    "richResponse": {
      "items": [
        {
          "structuredResponse": {
            "checkoutResponse": {
              "proposedOrder": {
                "otherItems": [
                  {
                    "name": "Delivery Fees",
                    "subLines": [],
                    "price": {
                      "type": "ESTIMATE",
                      "amount": {
                        "currencyCode": "USD",
                        "units": "3",
                        "nanos": 500000000
                      }
                    },
                    "type": "DELIVERY"
                  },
                  {
                    "name": "Tax",
                    "subLines": [],
                    "price": {
                      "type": "ESTIMATE",
                      "amount": {
                        "currencyCode": "USD",
                        "units": "1",
                        "nanos": 370000000
                      }
                    },
                    "type": "TAX"
                  },
                  {
                    "name": "Promotion",
                    "subLines": [],
                    "price": {
                      "type": "ESTIMATE",
                      "amount": {
                        "currencyCode": "USD",
                        "units": "-5",
                        "nanos": 0
                      }
                    },
                    "id": "OWG_ACTIVE_CODE",
                    "type": "DISCOUNT"
                  }
                ],
                "cart": {
                  "merchant": {
                    "id": "https://www.exampleprovider.com/merchant/id1",
                    "name": "Falafel Bite"
                  },
                  "lineItems": [
                    {
                      "name": "Pita Chips",
                      "type": "REGULAR",
                      "id": "sample_item_offer_id_1",
                      "quantity": 1,
                      "price": {
                        "type": "ESTIMATE",
                        "amount": {
                          "currencyCode": "USD",
                          "units": "2",
                          "nanos": 750000000
                        }
                      },
                      "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id1",
                      "extension": {
                        "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension"
                      }
                    }
                  ],
                  "promotions": [
                    {
                      "coupon": "OWG_ACTIVE_CODE"
                    }
                  ],
                  "extension": {
                    "@type": "type.googleapis.com/google.actions.v2.orders.FoodCartExtension",
                    "fulfillmentPreference": {
                      "fulfillmentInfo": {
                        "pickup": {
                          "pickupTimeIso8601": "P0M"
                        }
                      }
                    }
                  }
                },
                "totalPrice": {
                  "type": "ESTIMATE",
                  "amount": {
                    "currencyCode": "USD",
                    "units": "14",
                    "nanos": 860000000
                  }
                },
                "extension": {
                  "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderExtension",
                  "availableFulfillmentOptions": [
                    {
                      "fulfillmentInfo": {
                        "pickup": {
                          "pickupTimeIso8601": "P0M"
                        }
                      },
                      "expiresAt": "2018-04-10T01:20:08.471Z"
                    }
                  ]
                }
              },
              "paymentOptions": {
                "googleProvidedOptions": {
                  "tokenizationParameters": {
                    "tokenizationType": "PAYMENT_GATEWAY",
                    "parameters": {
                      "gateway": "stripe",
                      "stripe:publishableKey": "pk_live_stripe_client_key",
                      "stripe:version": "2017-04-06"
                    }
                  },
                  "supportedCardNetworks": [
                    "AMEX",
                    "DISCOVER",
                    "MASTERCARD",
                    "VISA",
                    "JCB"
                  ],
                  "prepaidCardDisallowed": true,
                  "billingAddressRequired": true
                }
              }
            }
          }
        }
      ]
    }
  }
}

CheckoutResponseMessage

CheckoutResponseMessage 是具有 checkoutResponseerrorStructuredResponse 中的 AppResponse

SubmitOrderResponseMessage

SubmitOrderResponseMessageStructuredResponse 中具有 orderUpdateAppResponse

FinalResponse

您对购物车结账或 SubmitOrderRequestMessage 的响应。

下表列出了 FinalResponse 类型的属性:

媒体资源 类型 说明
richResponse RichResponse

必填。

包含您对 CheckoutRequestMessage 或 SubmitOrderRequestMessage 的响应。

CheckoutResponse

下表列出了 CheckoutResponse 类型的属性:

媒体资源 类型 说明
proposedOrder ProposedOrder

必填。

用于交易的建议订单。

paymentOptions PaymentOptions

必填。

用户选择的默认付款方式。

additionalPaymentOptions 列表<PaymentOptions>

用户可使用的备选付款方式。

以下示例展示了 CheckoutResponse 元素:

示例

{
  "proposedOrder": {
    "id": "sample_proposed_order_id_1",
    "otherItems": [
      {
        "name": "New customer discount",
        "price": {
          "type": "ESTIMATE",
          "amount": {
            "currencyCode": "USD",
            "units": "-5",
            "nanos": -500000000
          }
        },
        "type": "DISCOUNT"
      },
      {
        "name": "Delivery fee",
        "price": {
          "type": "ESTIMATE",
          "amount": {
            "currencyCode": "USD",
            "units": "3",
            "nanos": 500000000
          }
        },
        "type": "DELIVERY"
      },
      {
        "name": "Tax",
        "price": {
          "type": "ESTIMATE",
          "amount": {
            "currencyCode": "USD",
            "units": "1",
            "nanos": 500000000
          }
        },
        "type": "TAX"
      }
    ],
    "cart": {
      "merchant": {
        "id": "https://www.exampleprovider.com/merchant/id1",
        "name": "Falafel Bite"
      },
      "lineItems": [
        {
          "name": "Pita Chips",
          "type": "REGULAR",
          "id": "sample_item_offer_id_1",
          "offerId": "https://www.exampleprovider.com/menu/item/offer/id1",
          "quantity": 1,
          "price": {
            "type": "ESTIMATE",
            "amount": {
              "currencyCode": "USD",
              "units": "2",
              "nanos": 750000000
            }
          },
          "subLines": [
            {
              "note": "Notes for this item."
            }
          ],
          "extension": {
            "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension",
            "options": [
              {
                "id": "sample_addon_offer_id_1",
                "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id1",
                "name": "Honey Mustard",
                "price": {
                  "currencyCode": "USD"
                },
                "quantity": 1
              },
              {
                "id": "sample_addon_offer_id_2",
                "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id2",
                "name": "BBQ Sauce",
                "price": {
                  "currencyCode": "USD",
                  "nanos": 500000000
                },
                "quantity": 1
              }
            ]
          }
        },
        {
          "name": "Chicken Shwarma Wrap",
          "type": "REGULAR",
          "id": "sample_item_offer_id_2",
          "offerId": "https://www.exampleprovider.com/menu/item/offer/id2",
          "quantity": 1,
          "price": {
            "type": "ESTIMATE",
            "amount": {
              "currencyCode": "USD",
              "units": "8"
            }
          },
          "extension": {
            "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension"
          }
        },
        {
          "name": "Greek Salad",
          "type": "REGULAR",
          "id": "sample_item_offer_id_3",
          "offerId": "https://www.exampleprovider.com/menu/item/offer/id3",
          "quantity": 1,
          "price": {
            "type": "ESTIMATE",
            "amount": {
              "currencyCode": "USD",
              "units": "9",
              "nanos": 990000000
            }
          },
          "extension": {
            "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension"
          }
        },
        {
          "name": "Prawns Biryani",
          "type": "REGULAR",
          "id": "sample_item_offer_id_4",
          "offerId": "https://www.exampleprovider.com/menu/item/offer/id4",
          "quantity": 1,
          "price": {
            "type": "ESTIMATE",
            "amount": {
              "currencyCode": "USD",
              "units": "15",
              "nanos": 990000000
            }
          },
          "extension": {
            "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension"
          }
        }
      ],
      "extension": {
        "@type": "type.googleapis.com/google.actions.v2.orders.FoodCartExtension",
        "fulfillmentPreference": {
          "fulfillmentInfo": {
            "delivery": {
              "deliveryTimeIso8601": "P90M"
            }
          }
        },
        "location": {
          "coordinates": {
            "latitude": 37.788783,
            "longitude": -122.41384
          },
          "formattedAddress": "1350 CHARLESTON ROAD, MOUNTAIN VIEW, CA, United States",
          "zipCode": "94043",
          "city": "Mountain View",
          "postalAddress": {
            "regionCode": "US",
            "postalCode": "94043",
            "administrativeArea": "CA",
            "locality": "Mountain View",
            "addressLines": [
              "1350 Charleston Road"
            ]
          },
          "notes": "Gate code is #111"
        }
      }
    },
    "totalPrice": {
      "type": "ESTIMATE",
      "amount": {
        "currencyCode": "USD",
        "units": "36",
        "nanos": 730000000
      }
    },
    "extension": {
      "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderExtension",
      "availableFulfillmentOptions": [
        {
          "fulfillmentInfo": {
            "delivery": {
              "deliveryTimeIso8601": "P0M"
            }
          },
          "expiresAt": "2017-07-17T12:30:00Z"
        }
      ]
    }
  },
  "paymentOptions": {
    "googleProvidedOptions": {
      "facilitationSpecification": "{\"apiVersion\": 2,\"apiVersionMinor\": 0,\"merchantInfo\": {  \"merchantId\": \"Merchant ID\",  \"merchantName\": \"Merchant Name\"},\"allowedPaymentMethods\": [  {    \"type\": \"CARD\",    \"parameters\": {      \"allowedAuthMethods\": [        \"PAN_ONLY\"      ],      \"allowedCardNetworks\": [        \"VISA\",        \"AMEX\",        \"MASTERCARD\"      ],      \"billingAddressRequired\": false    },    \"tokenizationSpecification\": {      \"type\": \"PAYMENT_GATEWAY\",      \"parameters\": {        \"stripe:publishableKey\": \"pk_test_OoPcJNnxI1rDXhBq8BiXO2wz00s1Xc92dA\",        \"gateway\": \"stripe\",        \"stripe:version\": \"2019-05-16\"      }    }  }],\"transactionInfo\": {  \"currencyCode\": \"AUD\",  \"totalPriceStatus\": \"ESTIMATED\",  \"totalPrice\": \"1.0\"}}"
    }
  },
  "additionalPaymentOptions": [
    {
      "actionProvidedOptions": {
        "paymentType": "ON_FULFILLMENT",
        "displayName": "Cash on delivery."
      }
    }
  ]
}

商品

包含您对购物车结账或 SubmitOrderRequestMessage 的响应。

下表列出了 Item 类型的属性:

媒体资源 类型 说明
structuredResponse StructuredResponse

必填。

RichResponse

包含您对购物车结账的响应。

下表列出了 RichResponse 类型的属性:

媒体资源 类型 说明
items 列表<Item>

必填。

必须正好有 1 项

StructuredResponse

对于 CheckoutResponseMessage,可以是以下值之一: CheckoutResponse 表示结帐成功。OR FoodErrorExtension:表示结账时失败。响应可以包含更正后的 ProposedOrder 和 PaymentOptions,或没有 PaymentOptions 的错误消息。对于 SubmitOrderResponseMessage,只有 orderUpdate 适用。

下表列出了 StructuredResponse 类型的属性:

媒体资源 类型 说明
以下属性组中只有以下一组属性:
checkoutResponse 分组 1 CheckoutResponse

结账的商品加上税费和折扣。

error 分组 2 FoodErrorExtension

在购物车中发现错误。根据错误的性质,此属性可能包含更正后的 ProposedOrder 和 PaymentOptions,也可能只包含不含 PaymentOptions 的错误消息。

orderUpdate 分组 3 OrderUpdate

异步订单更新

本部分介绍了构成典型订餐内置操作互动的请求和响应的高级类型。

AsyncOrderUpdateRequestMessage

在订单提交并确认后通知用户相关更改。 例如,您可以通知用户订单正在运输中或价格是否发生了变化。如需了解详情,请参阅

下表列出了 AsyncOrderUpdateRequestMessage 类型的属性:

媒体资源 类型 说明
isInSandbox Boolean

表示此次更新发送的顺序是沙盒付款。

customPushMessage CustomPushMessage

必填。

包含请求的 OrderUpdate。

以下示例展示了 AsyncOrderUpdateRequestMessage 元素:

示例

{
  "isInSandbox": true,
  "customPushMessage": {
    "orderUpdate": {
      "actionOrderId": "sample_action_order_id",
      "orderState": {
        "state": "IN_TRANSIT",
        "label": "Order is on the way"
      },
      "inTransitInfo": {
        "updatedTime": "2017-07-17T12:00:00Z"
      },
      "updateTime": "2017-07-17T12:00:00Z",
      "receipt": {
        "userVisibleOrderId": "userVisibleId1234"
      },
      "orderManagementActions": [
        {
          "type": "CUSTOMER_SERVICE",
          "button": {
            "title": "Contact customer service",
            "openUrlAction": {
              "url": "mailto:support@example.com"
            }
          }
        },
        {
          "type": "EMAIL",
          "button": {
            "title": "Email restaurant",
            "openUrlAction": {
              "url": "mailto:person@example.com"
            }
          }
        },
        {
          "type": "CALL_RESTAURANT",
          "button": {
            "title": "Call restaurant",
            "openUrlAction": {
              "url": "tel:+16505554679"
            }
          }
        }
      ],
      "infoExtension": {
        "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension",
        "estimatedFulfillmentTimeIso8601": "2017-07-17T13:00:00Z/2017-07-17T13:30:00Z"
      }
    }
  }
}

AsyncOrderUpdateResponseMessage

成功发送 AsyncOrderUpdateRequestMessage 后,Google 会返回 HTTP 200 状态和空正文。如果更新失败,Google 会回复并详细说明订单更新失败的原因。

订单更新类型

按钮

定义可添加以提供用户互动的用户界面元素。

下表列出了 Button 类型的属性:

媒体资源 类型 说明
title String

必填。

显示标签。句首字母大写,不得超过 30 个字符,以确保正确呈现。

示例:Contact us

openUrlAction OpenUrlAction

必填。

以下示例展示了 Button 元素:

示例

{
  "title": "Send us feedback",
  "openUrlAction": {
    "url": "mailto:person@example.com"
  }
}

CancellationInfo

下表列出了 CancellationInfo 类型的属性:

媒体资源 类型 说明
reason String

必填。

当 OrderState.state 为“CANCELLED”时,遭拒的可显示文本原因。

示例:Restaurant closed

以下示例展示了 CancellationInfo 元素:

示例

{
  "reason": "Insufficient inventory"
}

FoodOrderUpdateExtension

此类型为用户提供订单送达或取货的预计时间间隔。只要信息可用或自上次发送后发生了更改,请在 OrderUpdate 中发送此扩展程序。

保守估算履单间隔,以便始终如一地满足用户期望。例如,如果订单预计今天 13:00 送达,则您应发送与路况变化(例如今天的 12:45 到 13:15)一致的估算间隔。

ISO 8601 时长或时间戳被解释为从 OrderUpdateupdateTime(本质上为“现在”)到 updateTimeduration 的时间间隔。除非“现在”实际上是合理的预期,否则请勿使用此格式。

ISO 8601 间隔被解释为从开始到结束的间隔。

下表列出了 FoodOrderUpdateExtension 类型的属性:

媒体资源 类型 说明
@type 对比度

此扩展程序的类型。此字段始终设置为“type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension”。

值:type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension

estimatedFulfillmentTimeIso8601 String

订单商品送达或可以取货的预计时间。该字符串必须采用 ISO 8601 格式,并且必须对应于某个间隔,而不是单个固定时间。可接受的规范包括:间隔、持续时间和日期/时间。当信息可用或发生变更(例如提前或延迟到货)时,可以在 SubmitOrderResponseMessage 或 AsyncOrderUpdateRequestMessage 中发送此字段。

示例:2017-07-17T13:00:00Z/2017-07-17T13:30:00Z

foodOrderErrors 列表<FoodOrderError>

描述下单后发生的错误。建议每个购物车或每件商品出现一次错误。对于 RejectionInfo 未涵盖的任何错误,请使用 FoodOrderUpdateExtension.FoodOrderErrors。

不得少于 1 项

以下示例展示了 FoodOrderUpdateExtension 元素:

示例 1

{
  "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension",
  "estimatedFulfillmentTimeIso8601": "2017-07-17T13:00:00Z/2017-07-17T13:30:00Z"
}

示例 2

{
  "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension",
  "foodOrderErrors": [
    {
      "error": "NO_CAPACITY",
      "description": "Sorry, the restaurant cannot take your order right now."
    }
  ]
}

FulfillmentInfo

下表列出了 FulfillmentInfo 类型的属性:

媒体资源 类型 说明
以下属性组中只有以下一组属性:
deliveryTime 分组 1 ISO 时间戳

在 FoodOrderingUpdateExtension 消息中使用 EstimatedFulfillmentTimeIso8601

pickupTime 分组 2 ISO 时间戳

在 FoodOrderingUpdateExtension 消息中使用 EstimatedFulfillmentTimeIso8601

以下示例展示了 FulfillmentInfo 元素:

示例 1

{
  "deliveryTime": "2017-05-10T02:36:38.803Z"
}

示例 2

{
  "pickupTime": "2019-12-26T07:24:27.803Z"
}

InTransitInfo

下表列出了 InTransitInfo 类型的属性:

媒体资源 类型 说明
updatedTime ISO 时间戳

在 FoodOrderingUpdateExtension 消息中使用 EstimatedFulfillmentTimeIso8601

以下示例展示了 InTransitInfo 元素:

示例

{
  "updatedTime": "2017-05-10T02:36:38.803Z"
}

LineItemUpdate

下表列出了 LineItemUpdate 类型的属性:

媒体资源 类型 说明
orderState OrderState
price Price
reason String

更改原因。价格变动时必填。

以下示例展示了 LineItemUpdate 元素:

示例

{
  "orderState": {
    "state": "CONFIRMED",
    "label": "Provider confirmed"
  },
  "price": {
    "type": "ESTIMATE",
    "amount": {
      "currencyCode": "USD",
      "units": "5",
      "nanos": 500000000
    }
  },
  "reason": "Menu updated prices."
}

OpenUrlAction

下表列出了 OpenUrlAction 类型的属性:

媒体资源 类型 说明
url String

必填。

点击或触摸该按钮而触发的操作。适用的前缀列表取决于 orderManagementActionType。“EMAIL”:前缀必须为“mailto”。“CALL”:前缀必须是“tel”。“CUSTOMER_SERVICE”:前缀必须是“mailto”“tel”“http”或“https”。

示例:https://www.google.com

OrderManagementAction

通过订单管理功能,用户可以获取下单后支持,并且应在提交订单 AppResponse 内的每个 OrderUpdate 中发送,并且后续针对某个特定订单发送的每项 AsyncOrderUpdateRequestMessage 订单管理操作可能会因状态而异。

例如,在“CREATED”状态下,CUSTOMER_SERVICE 可能会引用您的客户服务电话。然后,在“已确认”状态下,CUSTOMER_SERVICE 可更改为餐厅的电话,前提是该电话成为客户的最佳联系人。同样,订单处于“FULFILLED”状态后,CUSTOMER_SERVICE 可引用您的支持电子邮件地址。

下表列出了 OrderManagementAction 类型的属性:

媒体资源 类型 说明
type OrderManagementActionType

必填。

button Button

必填。

以下示例展示了 OrderManagementAction 元素:

示例 1

{
  "type": "CUSTOMER_SERVICE",
  "button": {
    "title": "Contact customer service",
    "openUrlAction": {
      "url": "mailto:support@example.com"
    }
  }
}

示例 2

{
  "type": "EMAIL",
  "button": {
    "title": "Email restaurant",
    "openUrlAction": {
      "url": "mailto:person@example.com"
    }
  }
}

OrderManagementActionType

定义与 OrderManagementAction 相关的类型。

OrderManagementActionType 类型具有以下可能的值:

  • CUSTOMER_SERVICE:要显示在订单确认页面上的客户服务电子邮件地址和/或联系电话。这是必填字段。openUrlAction.url 前缀必须是“mailto”、“tel”、“http”或“https”。
  • EMAIL:仅限订单详情页面上的电子邮件操作。openUrlAction.url 前缀必须为“mailto”。
  • CALL_DRIVER:仅在订单详情页面上执行调用操作。openUrlAction.url 前缀必须为“tel”。
  • CALL_RESTAURANT:仅在订单详情页面上执行调用操作。openUrlAction.url 前缀必须为“tel”。

OrderState

订单的当前状态。OrderState 的每个 state 值也与 myaccount.google.com 上的购买状态相对应。

下表列出了 OrderState 类型的属性:

媒体资源 类型 说明
state OrderStateEnum

必填。

label String

必填。

状态的用户可见显示字符串。采用句首字母大写形式。

示例:Your order has been received

以下示例展示了 OrderState 元素:

示例

{
  "state": "CONFIRMED",
  "label": "Provider confirmed"
}

OrderStateEnum

定义与 OrderState 相关的类型。

OrderStateEnum 类型具有以下可能的值:

  • CREATED:订单由集成商创建,正在等待提供商确认。对应于“已订购”购买状态。
  • CONFIRMED:订单已由提供商确认且处于有效状态。对应于“已接受”购买交易状态。
  • REJECTED:订单被集成商或提供商拒绝。对应于“遭拒”购买交易状态。
  • CANCELLED:用户取消了订单。对应于“已取消”购买交易状态。
  • IN_PREPARATION:食物正在准备中。对应于“状态未知”购买状态。
  • READY_FOR_PICKUP:食物已可供取餐。对应于“可随时提货”购买状态。
  • IN_TRANSIT:订单正在送达。对应于“处理中”购买状态。
  • FULFILLED:用户收到了订购的商品。对应于“已自提”购买交易状态。

收据

在提交订单 AppResponse 中发送此类型,其中 OrderState 为“CONFIRMED”、“FULFILLED”或“IN_TRANS”。在 userVisibleOrderId 可用时发送收据。您无需在后续更新中继续发送收据。

下表列出了 Receipt 类型的属性:

媒体资源 类型 说明
userVisibleOrderId String

必填。

如果订单为“CONFIRMED”、“IN_TRANS”或“FULFILLED”,必须提供。此字段是此订单的面向用户的单个 ID(通常是餐馆的订单 ID),会同时显示在集成商的收据和 Google 订单卡片中。用户必须能够使用此 ID 引用他们向提供商和集成商提供的客户服务订单。您只需在任何给定的 OrderUpdate 中提供此 ID 一次。在提供该属性之前,actionOrderId 是 userVisibleOrderId。例如,在餐馆确认订单之前,您可能没有 userVisibleOrderId。确认后,您必须发送包含 OrderUpdate 和 Receipt 的 AsyncOrderUpdateRequestMessage。

以下示例展示了 Receipt 元素:

示例

{
  "userVisibleOrderId": "userVisibleId1234"
}

RejectionInfo

下表列出了 RejectionInfo 类型的属性:

媒体资源 类型 说明
type RejectionType

必填。

reason String

用于内部日志记录的拒绝原因。此字段对用户不可见。

以下示例展示了 RejectionInfo 元素:

示例

{
  "type": "PAYMENT_DECLINED",
  "reason": "There is an issue with payment processing."
}

RejectionType

RejectionType 类型具有以下可能的值:

  • INELIGIBLE:用户因政策或风险方面的顾虑而不符合条件。
  • PAYMENT_DECLINED:付款处理存在问题。
  • UNAVAILABLE_SLOT:订单无法按 DeliveryInfo 或 PickupInfo 指定的提前订单履行。
  • PROMO_NOT_APPLICABLE:促销活动存在问题。
  • UNKNOWN:任何其他原因。

与付款相关的类型

本部分介绍了订餐服务所用的付款相关类型。

ActionProvidedPaymentOptions

关于操作所提供的付款方式的要求。

下表列出了 ActionProvidedPaymentOptions 类型的属性:

媒体资源 类型 说明
paymentType PaymentType

必填。

displayName String

必填。

收据上显示的付款方式的名称。

示例:Taco Points Total

onFulfillmentPaymentData OnFulfillmentPaymentData

付款类型“ON_FULFILLMENT”的其他数据。例如,您可以使用此字段指定履单是否支持现金或卡。

以下示例展示了 ActionProvidedPaymentOptions 元素:

示例

{
  "paymentType": "ON_FULFILLMENT",
  "displayName": "Pay when you get your food.",
  "onFulfillmentPaymentData": {
    "supportedPaymentOptions": [
      "Cash",
      "Card"
    ]
  }
}

AllowedAuthMethods

AllowedAuthMethods 类型具有以下可能的值:

  • PAN_ONLY:与用户 Google 帐号中保存的支付卡相关联的身份验证方法。返回的付款数据包含个人帐号 (PAN) 以及到期月份和到期年份。

AllowedCardNetworks

AllowedCardNetworks 类型具有以下可能的值:

  • AMEX
  • DISCOVER
  • INTERAC
  • JCB
  • MASTERCARD
  • VISA

BillingAddressParameters

此对象可让您设置要针对所请求的账单邮寄地址返回的其他字段。

下表列出了 BillingAddressParameters 类型的属性:

媒体资源 类型 说明
format String

完成交易所需的账单邮寄地址格式。MIN:姓名、国家/地区代码和邮政编码。FULL:姓名、街道地址、市行政区、区域、国家/地区代码和邮政编码。

以下示例展示了 BillingAddressParameters 元素:

示例 1

{
  "format": "MIN"
}

示例 2

{
  "format": "FULL"
}

CardParameters

使用此对象可配置您的网站对 Google Pay API 的支持。

下表列出了 CardParameters 类型的属性:

媒体资源 类型 说明
allowedAuthMethods List<Const>

必填。

用于对卡交易进行身份验证的字段。

不得少于 1 项

allowedCardNetworks 列表<AllowedCardNetworks>

必填。

您支持且受 Google Pay API 支持的一个或多个支付卡网络。

不得少于 1 项

billingAddressRequired Boolean

如果您要求提供账单邮寄地址,请将此属性设为 true。请仅在需要处理交易时再请求提供帐单邮寄地址。额外的数据请求可能会让结账流程更顺畅,并导致转化率降低。

billingAddressParameters BillingAddressParameters

如果 billingAddressRequired 设置为 true,则返回预期字段。

cvcRequired Boolean

如果使用 TimesofMoney,则设置为 true,如果是所有其他付款处理方,则设置为 false。

以下示例展示了 CardParameters 元素:

示例 1

{
  "allowedAuthMethods": [
    "PAN_ONLY"
  ],
  "allowedCardNetworks": [
    "AMEX",
    "DISCOVER"
  ],
  "billingAddressRequired": false,
  "cvcRequired": false
}

示例 2

{
  "allowedAuthMethods": [
    "PAN_ONLY"
  ],
  "allowedCardNetworks": [
    "AMEX",
    "DISCOVER"
  ],
  "billingAddressRequired": true,
  "billingAddressParameters": {
    "format": "MIN"
  },
  "cvcRequired": false
}

GoogleProvidedPaymentInstrument

下表列出了 GoogleProvidedPaymentInstrument 类型的属性:

媒体资源 类型 说明
instrumentToken String

必填。

采用 Base64 编码的字符串,其中包含用于通过参与的 Google Pay 处理方向用户收费的付款令牌,按照先前指定的 GoogleProvidedPaymentOptions。

billingAddress PostalAddress

付款的账单邮寄地址。

以下示例展示了 GoogleProvidedPaymentInstrument 元素:

示例

{
  "instrumentToken": "abcd",
  "billingAddress": {
    "regionCode": "US",
    "postalCode": "94043",
    "administrativeArea": "CA",
    "locality": "Mountain View",
    "addressLines": [
      "1350 Charleston Road"
    ]
  }
}

GoogleProvidedPaymentOptions

针对 Google 提供的付款方式的要求。

下表列出了 GoogleProvidedPaymentOptions 类型的属性:

媒体资源 类型 说明
facilitationSpecification String

字符串形式的 PaymentDataRequest JSON。使用此对象可配置您的网站对 Google Pay API 的支持。

supportedCardNetworks 列表<SupportedCardNetworks>

请改用 facilitationSpecification。代理支持的支付卡网络类型。

此字段已弃用。

prepaidCardDisallowed Boolean

请改用 facilitationSpecification。是否允许使用预付卡作为付款方式。

此字段已弃用。

billingAddressRequired Boolean

请改用 facilitationSpecification。是否需要提供账单邮寄地址。

此字段已弃用。

tokenizationParameters TokenizationParameters

此字段已弃用。

以下示例展示了 GoogleProvidedPaymentOptions 元素:

示例 1

{
  "facilitationSpecification": "{\"apiVersion\": 2,\"apiVersionMinor\": 0,\"merchantInfo\": {  \"merchantId\": \"Merchant ID\",  \"merchantName\": \"Merchant Name\"},\"allowedPaymentMethods\": [  {    \"type\": \"CARD\",    \"parameters\": {      \"allowedAuthMethods\": [        \"PAN_ONLY\"      ],      \"allowedCardNetworks\": [        \"VISA\",        \"AMEX\",        \"MASTERCARD\"      ],      \"billingAddressRequired\": false    },    \"tokenizationSpecification\": {      \"type\": \"PAYMENT_GATEWAY\",      \"parameters\": {        \"stripe:publishableKey\": \"pk_test_OoPcJNnxI1rDXhBq8BiXO2wz00s1Xc92dA\",        \"gateway\": \"stripe\",        \"stripe:version\": \"2019-05-16\"      }    }  }],\"transactionInfo\": {  \"currencyCode\": \"AUD\",  \"totalPriceStatus\": \"ESTIMATED\",  \"totalPrice\": \"1.0\"}}"
}

示例 2

{
  "tokenizationParameters": {
    "tokenizationType": "PAYMENT_GATEWAY",
    "parameters": {
      "gateway": "braintree",
      "braintree:apiVersion": "v1",
      "braintree:sdkVersion": "1.4.0",
      "braintree:merchantId": "a1b2c3d4e5",
      "braintree:clientKey": "production_braintree_client_key",
      "braintree:authorizationFingerprint": "same_as_client_key"
    }
  },
  "supportedCardNetworks": [
    "AMEX",
    "DISCOVER",
    "MASTERCARD",
    "JCB",
    "VISA"
  ],
  "prepaidCardDisallowed": true
}

示例 3

{
  "tokenizationParameters": {
    "tokenizationType": "PAYMENT_GATEWAY",
    "parameters": {
      "gateway": "stripe",
      "stripe:publishableKey": "pk_live_stripe_client_key",
      "stripe:version": "2017-04-06"
    }
  },
  "supportedCardNetworks": [
    "AMEX",
    "DISCOVER",
    "MASTERCARD",
    "VISA",
    "JCB"
  ],
  "prepaidCardDisallowed": true,
  "billingAddressRequired": true
}

MerchantInfo

使用此对象可配置您的网站对 Google Pay API 的支持。

下表列出了 MerchantInfo 类型的属性:

媒体资源 类型 说明
merchantId String

Google Pay 向您发放的 Google 商家 ID。

merchantName String

必填。

采用 UTF-8 编码的商家名称。商家名称会显示在付款表格中。

OnFulfillmentPaymentData

使用此对象可发送付款方式“ON_FULFILLMENT”的其他数据。

下表列出了 OnFulfillmentPaymentData 类型的属性:

媒体资源 类型 说明
supportedPaymentOptions 列表<PaymentOptionsEnums>

履单时用户提供的付款方式列表。

以下示例展示了 OnFulfillmentPaymentData 元素:

示例

{
  "supportedPaymentOptions": [
    "Cash",
    "Card"
  ]
}

参数

定义与 TokenizationParameters 相关的类型。

下表列出了 Parameters 类型的属性:

媒体资源 类型 说明
gateway String

必填。

示例:braintree

gatewayMerchantId String
[additionalKey: string] String 其他键值对

以下示例展示了 Parameters 元素:

示例 1

{
  "gatewayMerchantId": "90412491",
  "gateway": "olo"
}

示例 2

{
  "gateway": "braintree",
  "braintree:apiVersion": "v1",
  "braintree:sdkVersion": "1.4.0",
  "braintree:merchantId": "YOUR_MERCHANT_ID",
  "braintree:clientKey": "YOUR_BRAINTREE_SANDVOX_OR_PRODUCTION_KEY"
}

PaymentDataRequest

使用此对象可配置您的网站对 Google Pay API 的支持。

下表列出了 PaymentDataRequest 类型的属性:

媒体资源 类型 说明
apiVersion 对比度

必填。

主要 API 版本。

值:2

apiVersionMinor 对比度

必填。

次要 API 版本。

值:0

merchantInfo MerchantInfo

必填。

(Google Pay 商家 ID)请求付款数据的商家的相关信息。

allowedPaymentMethods 列表<PaymentMethod>

必填。

指定是否支持 Google Pay API 支持的一种或多种付款方式。

transactionInfo TransactionInfo

必填。

有关根据用户是否同意交易来为交易授权的详细信息。此字段包含总价和价格状态。

以下示例展示了 PaymentDataRequest 元素:

示例

{
  "apiVersion": 2,
  "apiVersionMinor": 0,
  "merchantInfo": {
    "merchantId": "10391231",
    "merchantName": "Burrito Town"
  },
  "allowedPaymentMethods": [
    {
      "type": "CARD",
      "parameters": {
        "allowedAuthMethods": [
          "PAN_ONLY"
        ],
        "allowedCardNetworks": [
          "VISA",
          "AMEX",
          "MASTERCARD"
        ],
        "billingAddressRequired": true,
        "billingAddressParameters": {
          "format": "FULL"
        },
        "cvcRequired": false
      },
      "tokenizationSpecification": {
        "type": "PAYMENT_GATEWAY",
        "parameters": {
          "gateway": "stripe",
          "stripe:version": "2019-05-16",
          "stripe:publishableKey": "pk_test_OoPcJNnxI1rDXhBq8BiXO2wz00s1Xc92dA"
        }
      }
    }
  ],
  "transactionInfo": {
    "currencyCode": "INR",
    "totalPriceStatus": "ESTIMATED",
    "totalPrice": "185.00"
  }
}

PaymentInfo

订单的付款相关信息。

下表列出了 PaymentInfo 类型的属性:

媒体资源 类型 说明
displayName String

必填。

要在收据上显示的付款方式的用户可见名称。

paymentType PaymentType

必填。

googleProvidedPaymentInstrument GoogleProvidedPaymentInstrument

操作可使用的令牌。只有当您在 CheckoutResponseMessage 中将 GoogleProvidedPaymentOptions 指定为付款选项时,才应指定此字段。

以下示例展示了 PaymentInfo 元素:

示例 1

{
  "displayName": "Visa\u2006****\u20061111",
  "googleProvidedPaymentInstrument": {
    "instrumentToken": "abcd"
  },
  "paymentType": "PAYMENT_CARD"
}

示例 2

{
  "displayName": "Visa\u2006****\u20061111",
  "googleProvidedPaymentInstrument": {
    "instrumentToken": "abcd",
    "billingAddress": {
      "regionCode": "US",
      "postalCode": "94043",
      "administrativeArea": "CA",
      "locality": "Mountain View",
      "addressLines": [
        "123 Random Street",
        "Unit ABC"
      ],
      "recipients": [
        "sample_receipient"
      ]
    }
  },
  "paymentType": "PAYMENT_CARD"
}

PaymentMethod

使用此对象可配置您的网站对 Google Pay API 的支持。

下表列出了 PaymentMethod 类型的属性:

媒体资源 类型 说明
type 对比度

必填。

所支持付款方式的短标识符。目前仅支持 CARD。

值:CARD

parameters CardParameters

必填。

配置所提供的付款方式类型时所需的参数。

tokenizationSpecification TokenizationSpecification

必填。

配置要接收付款信息的帐号或解密提供商。CARD 付款方式必须提供此属性。

以下示例展示了 PaymentMethod 元素:

示例

{
  "type": "CARD",
  "parameters": {
    "allowedAuthMethods": [
      "PAN_ONLY"
    ],
    "allowedCardNetworks": [
      "VISA",
      "AMEX",
      "MASTERCARD"
    ],
    "billingAddressRequired": false
  },
  "tokenizationSpecification": {
    "type": "PAYMENT_GATEWAY",
    "parameters": {
      "gatewayMerchantId": "90412491",
      "gateway": "olo"
    }
  }
}

PaymentOptions

下表列出了 PaymentOptions 类型的属性:

媒体资源 类型 说明
以下属性组中只有以下一组属性:
googleProvidedOptions 分组 1 GoogleProvidedPaymentOptions

与 actionProvidedOptions 相互排斥。使用此付款方式通过 gPay 进行在线付款。

actionProvidedOptions 分组 2 ActionProvidedPaymentOptions

与 googleProvidedOptions 相互排斥。适用于“货到付款”或“履单付款”。

以下示例展示了 PaymentOptions 元素:

示例 1

{
  "googleProvidedOptions": {
    "facilitationSpecification": "{\"apiVersion\": 2,\"apiVersionMinor\": 0,\"merchantInfo\": {  \"merchantId\": \"Merchant ID\",  \"merchantName\": \"Merchant Name\"},\"allowedPaymentMethods\": [  {    \"type\": \"CARD\",    \"parameters\": {      \"allowedAuthMethods\": [        \"PAN_ONLY\"      ],      \"allowedCardNetworks\": [        \"VISA\",        \"AMEX\",        \"MASTERCARD\"      ],      \"billingAddressRequired\": false    },    \"tokenizationSpecification\": {      \"type\": \"PAYMENT_GATEWAY\",      \"parameters\": {        \"stripe:publishableKey\": \"pk_test_OoPcJNnxI1rDXhBq8BiXO2wz00s1Xc92dA\",        \"gateway\": \"stripe\",        \"stripe:version\": \"2019-05-16\"      }    }  }],\"transactionInfo\": {  \"currencyCode\": \"AUD\",  \"totalPriceStatus\": \"ESTIMATED\",  \"totalPrice\": \"1.0\"}}"
  }
}

示例 2

{
  "googleProvidedOptions": {
    "facilitationSpecification": "{\"apiVersion\": 2,\"apiVersionMinor\": 0,\"merchantInfo\": {  \"merchantId\": \"Merchant ID\",  \"merchantName\": \"Merchant Name\"},\"allowedPaymentMethods\": [  {    \"type\": \"CARD\",    \"parameters\": {      \"allowedAuthMethods\": [        \"PAN_ONLY\"      ],      \"allowedCardNetworks\": [        \"VISA\",        \"AMEX\",        \"MASTERCARD\"      ],      \"billingAddressRequired\":true,   \"billingAddressParameters\": {  \"format\":\"MIN\"  }    },    \"tokenizationSpecification\": {      \"type\": \"PAYMENT_GATEWAY\",      \"parameters\": {        \"stripe:publishableKey\": \"pk_test_OoPcJNnxI1rDXhBq8BiXO2wz00s1Xc92dA\",        \"gateway\": \"stripe\",        \"stripe:version\": \"2019-05-16\"      }    }  }],\"transactionInfo\": {  \"currencyCode\": \"AUD\",  \"totalPriceStatus\": \"ESTIMATED\",  \"totalPrice\": \"1.0\"}}"
  }
}

示例 3

{
  "actionProvidedOptions": {
    "paymentType": "ON_FULFILLMENT",
    "displayName": "Pay when you get your food.",
    "onFulfillmentPaymentData": {
      "supportedPaymentOptions": [
        "Cash",
        "Card"
      ]
    }
  }
}

PaymentOptionsEnums

PaymentOptionsEnums 类型具有以下可能的值:

  • Cash
  • Card
  • UPI
  • Paytm

PaymentType

PaymentType 类型具有以下可能的值:

  • PAYMENT_CARD:适用于 GoogleProvidedPaymentOptions。
  • ON_FULFILLMENT:适用于 ActionProvidedPaymentOptions。

SupportedCardNetworks

定义与 GoogleProvidedPaymentOptions 相关的类型。

SupportedCardNetworks 类型具有以下可能的值:

  • UNSPECIFIED_CARD_NETWORK
  • AMEX
  • DISCOVER
  • JCB
  • MASTERCARD
  • VISA

TokenizationParameters

定义与 GoogleProvidedPaymentOptions 相关的类型。

下表列出了 TokenizationParameters 类型的属性:

媒体资源 类型 说明
tokenizationType Enum [ "UNSPECIFIED_TOKENIZATION_TYPE", "PAYMENT_GATEWAY" ]

必填。

请改用 facilitationSpecification。接受的令牌类型。

parameters Parameters

请改用 facilitationSpecification。

TokenizationSpecification

借助此对象,您可以配置要接收可扣款付款信息的帐号。

下表列出了 TokenizationSpecification 类型的属性:

媒体资源 类型 说明
type 对比度

必填。

parameters Parameters

必填。

以下示例展示了 TokenizationSpecification 元素:

示例 1

{
  "type": "PAYMENT_GATEWAY",
  "parameters": {
    "gatewayMerchantId": "1247192",
    "gateway": "cybersource"
  }
}

示例 2

{
  "type": "PAYMENT_GATEWAY",
  "parameters": {
    "gateway": "stripe",
    "stripe:version": "2018-10-31",
    "stripe:publishableKey": "12378127"
  }
}

TransactionInfo

此对象描述了确定付款人能否付款的交易。它用于显示付款授权对话框。

下表列出了 TransactionInfo 类型的属性:

媒体资源 类型 说明
currencyCode String

必填。

ISO 4217 字母货币代码。

transactionId String

用于标识交易尝试的唯一 ID。商家可以使用现有 ID 或生成特定 ID 来进行 Google Pay 交易尝试。当您向 Google Transaction Events API 发送回调时,此字段为必填字段。

totalPriceStatus 对比度

必填。

使用“ESTIMATED”作为默认值。总价可能会根据回复的详细信息(例如根据账单邮寄地址收取的销售税)进行调整。

值:ESTIMATED

totalPrice String

必填。

交易的总货币价值,可选择是否精确到小数点后两位。此字段的值应与 cart.totalPrice 相同。

以下示例展示了 TransactionInfo 元素:

示例

{
  "totalPriceStatus": "ESTIMATED",
  "totalPrice": "12.34",
  "currencyCode": "USD"
}