This overview summarizes the Food Ordering flow and how it interacts with your fulfillment web service.
Ordering
The Food Ordering 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.
Cart validation
Cart validation is the first call made by Google to your web service endpoint.
Your web service is responsible for validating the Cart
by confirming
availability and pricing of items, computing and returning taxes, discounts,
and fees, and validating the order delivery address.
The checkout process follows this sequence:
- The Food Ordering service sends a
CheckoutRequestMessage
containing aCart
to your fulfillment web service endpoint - Your web service should validate the items in the
Cart
based on current prices, availability and service providers. You should then calculate the total price including discounts, taxes and delivery fees. - Your endpoint responds with a
CheckoutResponseMessage
containing the unmodifiedCart
for successful requests. AFoodErrorExtension
can be included in theCheckoutResponseMessage
to raise a processing error or propose minor changes, if necessary.
Once the Cart
is validated, the user may choose to proceed to the Order
submission stage of the flow.
Order submission
The order submission stage is triggered when the user places their order. Your web service is responsible for re-validating the cart, processing the card token, if online payments are enabled, and finally updating the status of the order.
The order submission process follows this sequence:
- Food Ordering service sends a
SubmitOrderRequestMessage
containing anOrder
to your fulfillment web service endpoint. Your backend should again performCart
validation before continuing. Your web service processes payment details found in the
Order
, typically performing the following actions:- Perform token verification, fraud and other eligibility checks
- Authorize and, optionally, charge the card
Your endpoint responds with a
SubmitOrderResponseMessage
containing anOrderUpdate
with a state ofCREATED
("Ordered" purchase status),CONFIRMED
("Accepted" purchase status), orREJECTED
("Declined" purchase status).
With the order placed, the user expects to receive order status updates from both you and the Food Ordering user interface. You are required to send an order confirmation email to the user. Additionally, you use Asynchronous Order Update Actions to send relevant order updates to your customers.
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:
- Changes to
OrderState
such as transitions fromCREATED
toCONFIRMED
, andCONFIRMED
toIN_TRANSIT
. - Changes to order items, such as price or availability
- 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
containing an OrderUpdate
. Google will
respond with an AsyncOrderUpdateResponseMessage
.
Client Libraries
The client code generator in the Tools section is available to validate your web service against the Fulfillment API specification.
Sequence diagram
This illustration demonstrates how fulfillment Actions interact with your web service. Click to enlarge.