How to add the delivery address details to the order preview?

最后都变了- 提交于 2019-12-06 03:42:08

Based on the error you're getting, it looks like the URI value for @type is incorrect.

Since you're already building a ProposedObject, you will need to use a @type: type.googleapis.com/google.actions.v2.orders.GenericExtension inside of the extension field of the ProposedObject (note orders in the URI). Per the docs you mentioned, GenericExtension will have a locations array that will contain an object of type OrderLocation where you can specify the delivery address.

The final JSON for an extension will look like:

"extension": {
    "@type": "type.googleapis.com/google.actions.v2.orders.GenericExtension",
    "locations": [
        {
          type: 'DELIVERY',
          location: {
            "postalAddress": {
            "regionCode": "USA",
            "recipients": [
                "Me"
             ],
            },
           "phoneNumber": "123456789" 
          }
        }
    ]
}

The rest of ProposedOrder fields will be the same as in your example.

Please see an example of using Transactions API in the official sample for more details.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!