Transaction API 将于 2023 年 5 月 3 日弃用,在此之前,会话操作将于 2023 年 6 月 13 日停用。如需了解详情,请参阅
对话型 Action 停用。
Method: orders.createWithCustomToken
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
使用由 Google 创建的自定义令牌创建并返回新订单。使用此方法的开发者应设置 Google 在请求中传递的 userToken。如果开发者/商家代表订单(而不是交易和 AMP 流程)直接将订单保存到 Google,则可以使用此方法。
HTTP 请求
POST https://actions.googleapis.com/v3/orders:createWithCustomToken
网址采用 gRPC 转码语法。
请求正文
请求正文中包含结构如下的数据:
字段 |
header |
object (OrderRequestHeader )
必需:创建订单请求的标头。
|
order |
object (Order )
必需:要创建的订单。 注意:1.要创建有效订单,以下字段始终是必填字段:order.create_time、order.merchant_order_id、order.contents.line_items、order.contents.line_items.id 2.订单中必须至少包含 1 个订单项,并且订单项必须已定义行业/附加信息。3. 所有附加信息(包括订单级和订单项级)都必须映射到 1 种行业类型,即如果一个订单代表多个行业,就不是有效的订单。
|
userToken |
string
必需:Google 通过异步渠道向合作伙伴提供的加密令牌。
|
响应正文
如果成功,则响应正文包含一个 Order
实例。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eCreates new Orders using a custom token provided by Google, enabling developers to save orders directly on behalf of the user.\u003c/p\u003e\n"],["\u003cp\u003eRequires a \u003ccode\u003ePOST\u003c/code\u003e request to \u003ccode\u003ehttps://actions.googleapis.com/v3/orders:createWithCustomToken\u003c/code\u003e with specific data in the request body.\u003c/p\u003e\n"],["\u003cp\u003eThe request body must contain \u003ccode\u003eheader\u003c/code\u003e, \u003ccode\u003eorder\u003c/code\u003e, and \u003ccode\u003euserToken\u003c/code\u003e fields with specified data structures and requirements.\u003c/p\u003e\n"],["\u003cp\u003eA successful response returns the created \u003ccode\u003eOrder\u003c/code\u003e object with details of the order.\u003c/p\u003e\n"]]],["This describes the process of creating a new order using a custom Google-minted token. A `POST` request is sent to `https://actions.googleapis.com/v3/orders:createWithCustomToken`. The request body requires a JSON payload with `header`, `order` (including `create_time`, `merchant_order_id`, and at least one valid `line_item` with an ID and vertical extension), and `userToken` (an encrypted token from Google). A successful request returns an `Order` instance in the response body.\n"],null,["# Method: orders.createWithCustomToken\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Request body](#body.request_body)\n - [JSON representation](#body.request_body.SCHEMA_REPRESENTATION)\n- [Response body](#body.response_body)\n\nCreates and returns the new Order using a custom token minted by google. Developers using this method should set the userToken passed by google in the request. This method is used in cases where developers/merchant directly saves orders to Google on behalf of order (instead of Transactions and AMP flow).\n\n### HTTP request\n\n`POST https://actions.googleapis.com/v3/orders:createWithCustomToken`\n\nThe URL uses [gRPC Transcoding](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto) syntax.\n\n### Request body\n\nThe request body contains data with the following structure:\n\n| JSON representation ||\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| ``` { \"header\": { object (/assistant/df-asdk/transactions/reference/physical/rest/v3/OrderRequestHeader) }, \"order\": { object (/assistant/df-asdk/transactions/reference/physical/rest/v3/Order) }, \"userToken\": string } ``` |\n\n| Fields ||\n|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `header` | `object (`[OrderRequestHeader](/assistant/df-asdk/transactions/reference/physical/rest/v3/OrderRequestHeader)`)` Required: Header for the create order request. |\n| `order` | `object (`[Order](/assistant/df-asdk/transactions/reference/physical/rest/v3/Order)`)` Required: Order to be created. Note: 1. Following fields are always required to create a valid order: order.create_time, order.merchant_order_id, order.contents.line_items, order.contents.line_items.id 2. Order must have at-least 1 line item and line item must have defined vertical/extension. 3. All extensions (both at order level and line_item level) must map to 1 vertical type ie. an order is not a valid order if it represents more than 1 vertical. \u003cbr /\u003e |\n| `userToken` | `string` Required: Encrypted token provided to partner by Google via asynchronous channel. |\n\n### Response body\n\nIf successful, the response body contains an instance of [Order](/assistant/df-asdk/transactions/reference/physical/rest/v3/Order)."]]