Overview

This overview summarizes the Order with Google flow and how it interacts with your fulfillment web service.

Ordering

The Order with Google user interface handles all interactions with the user as they add menu items to their order and decide on pickup or delivery, depending on the services offered by the restaurant. This experience is powered by the Restaurant, Service, and Menu entities found in your data feeds.

The next step is the cart validation stage where the resulting Cart created by the user is processed by your web service.

Checkout Action

Checkout action is the first call made by Google to your web service endpoint. Your web service is responsible for the validation of the Cart. You must confirm the availability and pricing of items, compute and return taxes, discounts, and fees, and validate the order delivery address.

The checkout process follows this sequence:

  1. The Order with Google service sends a CheckoutRequestMessage that contains a Cart to your fulfillment web service endpoint.
  2. Your web service needs to validate the items in the Cart based on current prices, availability, and service providers. You then calculate the total price, which includes discounts, taxes, and delivery fees.
  3. Your endpoint responds with a CheckoutResponseMessage that contains the unmodified Cart for successful requests. A FoodErrorExtension can be included in the CheckoutResponseMessage to raise a processing error or propose minor changes, if necessary.

After the Cart is validated, the user might choose to proceed to the order submission stage of the flow.

Submit Order Action

The submit order action is triggered when the user places their order. Your web service must revalidate the cart, process the card token if online payments are enabled, and finally update the status of the order.

The order submission process follows this sequence:

  1. The Order with Google service sends a SubmitOrderRequestMessage that contains an Order to your fulfillment web service endpoint. Your backend needs to perform another Cart validation before continuing.
  2. Your web service processes the payment details found in the Order, typically performing the following actions:

    1. Perform token verification, fraud, and other eligibility checks.
    2. Authorize and, optionally, charge the card.
  3. Your endpoint responds with a SubmitOrderResponseMessage that contains an OrderUpdate with a state of CREATED ("Ordered" purchase status), CONFIRMED ("Accepted" purchase status), or REJECTED ("Declined" purchase status).

With the order placed, the user expects to receive order status updates from both you and the Order with Google user interface. You are required to send an order confirmation email to the user. Additionally, you use the Asynchronous Order Update API to send relevant order updates to Google.

Asynchronous Order Update Action

Independent of any user notifications on your end, you must also send order status updates to Google for the following events:

  1. Changes to OrderState such as transitions from CREATED to CONFIRMED, and CONFIRMED to IN_TRANSIT.
  2. Changes to order items, such as price or availability.
  3. Whenever the user triggers a support request from one of your customer support channels.

Updates are sent from your web service endpoint as an AsyncOrderUpdateRequestMessage that contains an OrderUpdate. Google responds with an AsyncOrderUpdateResponseMessage.

Sequence diagram

The following illustration demonstrates how fulfillment actions interact with your web service. Click to enlarge.

Order with Google fulfillment flow

Set up your fulfillment endpoint

The Order with Google actions use JSON messages to communicate with your web service and handle the processing, confirmation, and updates to food orders. When you design your Order with Google web service, you must define a URL endpoint that receives request messages from the Order with Google service and can return messages back to the Google service. Your implementation must meet the following requirements:

  • Your web service must be able to receive a JSON message as a POST request from the Order with Google service.
  • Your web service must provide a publicly accessible URL endpoint, called the fulfillment URL, which you specify in the Actions Console. The fulfillment URL is used to check out and submit orders. Your implementation must handle both types of requests.
  • Your web service must be able to verify messages from Google using the Message verification method.
  • Your implementation of the URL endpoint must be able to handle both checkout and order fulfillment with a single endpoint. You can't have one URL endpoint for checkout and a separate endpoint for ordering submission.

Client Libraries

The client code generator in the Tools section is available to validate your web service against the Fulfillment API specification.