การแมปฟีดเมนูกับรายการในรถเข็นสำหรับการดำเนินการตามคำสั่งซื้อ
เมื่อลูกค้าเพิ่มสินค้าจากฟีดเมนูลงในรถเข็นและชำระเงิน Google จะส่งสินค้าเหล่านั้นไปยังปลายทางการดำเนินการตามคำสั่งซื้อเพื่อยืนยันราคาและความพร้อมจำหน่ายสินค้า เมื่อราคาและห้องว่างได้รับการตรวจสอบแล้ว ลูกค้าจะสั่งซื้อได้ ส่วนนี้จะแสดงวิธีแมปรายการฟีดเมนูกับรายการรถเข็นสำหรับการดำเนินการตามคำสั่งซื้อ
ตัวอย่างในส่วนนี้เป็นฟีดเมนูและสคีมารถเข็นเวอร์ชันที่ตัดข้อมูลบางส่วนออก ระบบจะแสดงเฉพาะช่องที่เกี่ยวข้องกับการแมประหว่างฟีดเมนูกับออบเจ็กต์รถเข็นเท่านั้น ดูสคีมาฉบับเต็มได้ที่ Menu
และ Cart
ระบบจะส่งสินค้าในฟีด Menu
ที่เพิ่มลงในรถเข็นในออบเจ็กต์ Cart
สําหรับทั้งการชำระเงินและการส่งคําสั่งซื้อ
MenuItem
ธรรมดาจะแสดงเป็นLineItem
ในอาร์เรย์lineItems
โดยที่offerId
คือoffer.id
ของรายการเมนูที่เลือกในฟีดเมนูMenuItem
ที่มีMenuItemOption
ที่ต้องระบุจะแสดงเป็นLineItem
ในอาร์เรย์lineItems
โดยที่offerId
คือoffer.id
ของตัวเลือกรายการเมนูที่เลือกจากฟีดเมนูAddOnMenuItem
ของLineItem
จะแสดงเป็นFoodItemOption
ในอาร์เรย์options
ของFoodItemExtension
แต่ละตัวเลือกจะมีofferId
ที่สอดคล้องกับoffer.id
ของรายการในเมนูส่วนเสริมที่เลือกจากฟีดเมนู โปรดทราบว่า AddOnMenuItem อาจมี AddOnMenuItem ที่ฝังอยู่ซึ่งแสดงเป็นsubOptions
ภายในตัวเลือกแต่ละรายการ
ตัวอย่างต่อไปนี้จะแมปรายการเมนูระหว่างฟีดเมนูกับรถเข็นการดำเนินการตามคำสั่งซื้อ
ตัวอย่างนี้มีรายการเมนูแบบง่าย
รายการในเมนูของฟีดเมนู:
{ "@type": "Menu", "@id": "menu_id", "hasMenuItem": [ { "@type": "MenuItem", "@id": "menuitem_id_1", "offers": [ { "@type": "Offer", "@id": "menuitem_offer_id_1", "price": "p_1", "priceCurrency": "USD" } ] }, { "@type": "MenuItem", "@id": "menuitem_id_2", "offers": [ { "@type": "Offer", "@id": "menuitem_offer_id_2", "price": "p_2", "priceCurrency": "USD" } ] } ] }
รายการเมนูที่แมปกับรถเข็นสำหรับการดำเนินการตามคำสั่งซื้อ
{ "@type": "Cart", "lineItems": [ { "offerId": "menuitem_offer_id_1", "price": { "amount": { "currencyCode": "USD", "units": "dollar(q_1*p_1)", "nanos": "cent(q_1*p_1)" } }, "quantity": "q_1" }, { "offerId": "menuitem_offer_id_2", "price": { "amount": { "currencyCode": "USD", "units": "dollar(q_2*p_2)", "nanos": "cent(q_2*p_2)" } }, "quantity": "q_2" } ] }
ตัวอย่างนี้มีรายการเมนูที่มี AddOnMenuItem อย่างน้อย 1 รายการ
รายการในเมนูของฟีดเมนู
{ "@type": "Menu", "@id": "menu_id", "hasMenuItem": [ { "@type": "MenuItem", "@id": "menuitem_id_1", "offers": [ { "@type": "Offer", "@id": "menuitem_offer_id_1", "price": "p_1", "priceCurrency": "USD" } ], "menuAddOn": [ { "@type": "MenuAddOnSection", "@id": "menuaddon_section_id_1", "hasMenuItem": [ { "@type": "AddOnMenuItem", "@id": "menuitem_addon_id_1", "offers": [ { "@type": "Offer", "@id": "menuitem_addon_offer_id_1", "price": "addon_p_1", "priceCurrency": "USD" } ] }, { "@type": "AddOnMenuItem", "@id": "menuitem_addon_id_2", "offers": [ { "@type": "Offer", "@id": "menuitem_addon_offer_id_2", "price": "addon_p_2", "priceCurrency": "USD" } ] } ] } ] }, { "@type": "MenuItem", "@id": "menuitem_id_2", "offers": [ { "@type": "Offer", "@id": "menuitem_offer_id_2", "price": "p_2", "priceCurrency": "USD" } ] } ] }
รายการเมนูที่แมปกับรถเข็นสำหรับการดำเนินการตามคำสั่งซื้อ
{ "@type": "Cart", "lineItems": [ { "offerId": "menuitem_offer_id_1", "price": { "amount": { "currencyCode": "USD", "units": "dollar(q_1*(p_1 + addon_q_1*addon_p_1 + addon_q_2*addon_p_2))", "nanos": "cent(q_1*(p_1 + addon_q_1*addon_p_1 + addon_q_2*addon_p_2))" } }, "quantity": "q_1", "extension": { "@type": "FoodItemExtension", "options": [ { "offerId": "menuitem_addon_offer_id_1", "price": { "currencyCode": "USD", "units": "dollar(addon_q_1*addon_p_1)", "nanos": "cent(addon_q_1*addon_p_1)" }, "quantity": "addon_q_1" }, { "offerId": "menuitem_addon_offer_id_2", "price": { "currencyCode": "USD", "units": "dollar(addon_q_2*addon_p_2)", "nanos": "cent(addon_q_2*addon_p_2)" }, "quantity": "addon_q_2" } ] } }, { "offerId": "menuitem_offer_id_2", "price": { "amount": { "currencyCode": "USD", "units": "dollar(q_2*p_2)", "nanos": "cent(q_2*p_2)" } }, "quantity": "q_2" } ] }
ตัวอย่างนี้มีรายการในเมนูที่มีตัวเลือกรายการในเมนู, AddOnMenuItems และ AddOnMenuItems ที่ฝังอยู่
รายการในเมนูของฟีดเมนู:
{ "@type": "MenuItem", "@id": "menuitem_id_1", "hasMenuItemOptions": [ { "@type": "MenuItemOption", "value": { "@type": "PropertyValue", "name": "OPTION", "value": "Large", "offers": [ { "@type": "Offer", "@id": "menuitem_option_offer_id_1", "price": "p_1", "priceCurrency": "USD" } ], "menuAddOn": [ { "@type": "AddOnMenuSection", "@id": "menuitem_option_addon_section_id_1", "hasMenuItem": [ { "@type": "AddOnMenuItem", "@id": "menuitem_option_addon_id_1", "offers": [ { "@type": "Offer", "@id": "menuitem_option_addon_offer_id_1", "price": "addon_p_1", "priceCurrency": "USD" } ] }, { "@type": "AddOnMenuItem", "@id": "menuitem_option_addon_id_2", "offers": [ { "@type": "Offer", "@id": "menuitem_option_addon_offer_id_2", "price": "addon_p_2", "priceCurrency": "USD" } ], "menuAddOn": [ { "@type": "AddOnMenuSection", "@id": "menuitem_option_subaddon_section_id_1", "hasMenuItem": [ { "@type": "AddOnMenuItem", "@id": "menuitem_option_subaddon_id_1", "offers": [ { "@type": "Offer", "@id": "menuitem_option_subaddon_offer_id_1", "price": "subaddon_p_1", "priceCurrency": "USD" } ] } ] } ] } ] } ] } } ] }
รายการเมนูที่แมปกับรถเข็นสำหรับการดำเนินการตามคำสั่งซื้อ
{ "@type": "Cart", "lineItems": [ { "offerId": "menuitem_option_offer_id_1", "price": { "amount": { "currencyCode": "USD", "units": "dollar(q_1*(p_1 + addon_q_1*addon_p_1 + addon_q_2*(addon_p_2 + subaddon_q_1*subaddon_p_1)))", "nanos": "cent(q_1*(p_1 + addon_q_1*addon_p_1 + addon_q_2*(addon_p_2 + subaddon_q_1*subaddon_p_1)))" } }, "quantity": "q_1", "extension": { "@type": "FoodItemExtension", "options": [ { "offerId": "menuitem_option_addon_offer_id_1", "price": { "currencyCode": "USD", "units": "dollar(addon_q_1*addon_p_1)", "nanos": "cent(addon_q_1*addon_p_1)" }, "quantity": "addon_q_1" }, { "offerId": "menuitem_option_addon_offer_id_2", "price": { "currencyCode": "USD", "units": "dollar(addon_q_2*(addon_p_2 + subaddon_q_1*subaddon_p_1))", "nanos": "cent(addon_q_2*(addon_p_2 + subaddon_q_1*subaddon_p_1))" }, "quantity": "addon_q_2", "subOptions": [ { "offerId": "menuitem_option_subaddon_offer_id_1", "price": { "currencyCode": "USD", "units": "dollar(subaddon_q_1*subaddon_p_1)", "nanos": "cent(subaddon_q_1*subaddon_p_1)" }, "quantity": "subaddon_q_1" } ] } ] } } ] }
การจัดการข้อผิดพลาด
หากพบปัญหาขณะประมวลผล CheckoutRequestMessage
คุณสามารถตอบกลับด้วย CheckoutResponseMessage
ที่มี FoodErrorExtension
แทน CheckoutResponse คุณสามารถใช้คําตอบนี้เพื่อระบุข้อผิดพลาดอย่างน้อย 1 รายการที่เกิดขึ้นระหว่างการประมวลผล
วิธีจัดการข้อผิดพลาดมี 2 วิธีดังนี้
- ข้อผิดพลาดที่แก้ไขได้: ผู้ใช้ไม่จําเป็นต้องแก้ไขรถเข็นเพื่อส่งคำสั่งซื้อ ตัวอย่างเช่น หากพิจารณาว่าสินค้าใน
Cart
มีการเปลี่ยนแปลงราคา คุณสามารถตอบกลับด้วยFoodOrderError
ของประเภทข้อผิดพลาดPRICE_CHANGED
พร้อมกับcorrectedProposedOrder
และpaymentOptions
Google จะแจ้งให้ผู้ใช้ทราบถึงการเปลี่ยนแปลง แต่อนุญาตให้ผู้ใช้ส่งไฟล์ที่มีcorrectedProposedOrder
นอกจากนี้ ผู้ใช้ยังย้อนกลับไปแก้ไขรถเข็นได้หากต้องการ คุณจะได้รับCheckoutRequestMessage
ใหม่หรือSubmitOrderRequestMessage
- ข้อผิดพลาดที่กู้คืนไม่ได้: ผู้ใช้ต้องแก้ไขรถเข็นก่อนส่งคำสั่งซื้อ ตัวอย่างเช่น หากพิจารณาว่าร้านอาหารปิดอยู่ คุณสามารถตอบกลับด้วย
FoodOrderError
ของข้อผิดพลาดประเภทCLOSED
Google จะแจ้งให้ผู้ใช้ทราบและจัดการการโต้ตอบเพื่ออัปเดตเป็นร้านอาหารใหม่ คุณจะได้รับCheckoutRequestMessage
ใหม่สำหรับรถเข็นใหม่
โดยทั่วไปแล้ว ให้ตั้งค่าให้ข้อผิดพลาดระดับรถเข็นไม่สามารถกู้คืนได้ แต่ข้อผิดพลาดระดับสินค้ากู้คืนได้ ดูรายการประเภทข้อผิดพลาดทั้งหมดและความหมายได้ที่
FoodOrderError
การจัดการกับการเปลี่ยนแปลงราคา
การเปลี่ยนแปลงราคาระหว่างชำระเงิน
หากพบปัญหาเกี่ยวกับราคาขณะประมวลผลการขอชำระเงินของลูกค้า ให้ทำดังนี้
- ตอบกลับ
CheckoutRequestMessage
ด้วยCheckoutResponseMessage
ที่มีFoodErrorExtension
ตามที่อธิบายไว้ในการจัดการข้อผิดพลาด - ในการตอบกลับข้อผิดพลาด ให้ใช้
correctedProposedOrder.cart
เพื่ออัปเดตราคาเป็นค่าที่ถูกต้อง Google ได้รับคำสั่งซื้อที่แก้ไขแล้วและอาจออกCheckoutRequestMessage
ใหม่
หลังจากชำระเงินแล้ว Google จะแสดงหน้ายืนยันคำสั่งซื้อต่อผู้ใช้ปลายทาง ไม่ว่าจะมีการเปลี่ยนแปลง ProposedOrder
หรือไม่ก็ตาม
หากแก้ไข ProposedOrder แล้ว Google อาจแสดงคำเตือนเพิ่มเติมเพื่อแจ้งให้ผู้ใช้ทราบถึงการเปลี่ยนแปลง หากผู้ใช้ตกลงที่จะสั่งซื้อ ระบบจะไม่ส่งคำขอชำระเงินอีก ขั้นตอนจะส่งคำสั่งซื้อต่อโดยใช้ ProposedOrder
ที่แก้ไขแล้ว
อย่างไรก็ตาม ผู้ใช้เปลี่ยนใจและแก้ไขรถเข็นได้ทุกเมื่อ เมื่อรถเข็นอัปเดตด้วยวิธีนี้ Google จะส่ง CheckoutRequestMessage
ใหม่
การเปลี่ยนแปลงราคาระหว่างส่งคำสั่งซื้อ
หากคุณพบปัญหาเกี่ยวกับราคาขณะประมวลผลการส่งคำสั่งซื้อ (มีการเรียกใช้ความตั้งใจ actions.intent.TRANSACTION_DECISION
) อย่าตอบกลับพร้อมข้อผิดพลาดหรืออัปเดตราคาในการตอบกลับ หากราคา จำนวน หรือรายละเอียดอื่นๆ ใน SubmitOrderRequestMessage
ไม่ตรงกับข้อมูลของคุณ ให้ตอบกลับโดยตั้งค่า orderState
เป็น REJECTED
เพื่อระบุว่าไม่สามารถสั่งซื้อได้ตามคำขอ
จากนั้นหากคำสั่งซื้อและรายละเอียดการชำระเงินถูกต้อง ให้ตั้งค่า orderState
เป็น CREATED
หรือ CONFIRMED
นอกจากนี้ ให้ใส่ actionOrderId
เพื่อแสดงรหัสคำสั่งซื้อในระบบ ต้องใช้รหัสนี้เมื่อส่งการอัปเดตในภายหลัง
หากประมวลผลการชำระเงินไม่ได้และส่ง SubmitOrderRequestMessage
ไปแล้ว คุณสามารถส่ง AsyncOrderUpdateRequestMessage
โดยตั้งค่า orderState
เป็น REJECTED
เพื่อแจ้งให้ผู้ใช้ทราบว่าคำสั่งซื้อจะไม่ผ่าน
ราคาเปลี่ยนแปลงหลังจากส่งคำสั่งซื้อ
หากพิจารณาว่าราคามีการเปลี่ยนแปลงจากราคาที่ใช้เมื่อลูกค้าส่งคำสั่งซื้อ คุณสามารถออก AsyncOrderUpdateRequestMessage
พร้อมราคาใหม่ได้ ตามที่อธิบายไว้ในการใช้การอัปเดตคำสั่งซื้อแบบไม่พร้อมกัน
วิธีอัปเดตราคาโดยใช้การอัปเดตคำสั่งซื้อแบบแอซิงค์
- เปลี่ยนราคาใน
lineItemUpdates[x].price
ค่านี้แสดงต้นทุนรวมของสินค้า ซึ่งรวมถึงส่วนเสริมและคูณด้วยจำนวน (ดูข้อมูลเพิ่มเติมได้ที่คำอธิบายของช่องprice
ในLineItem
) - ป้อนคำอธิบายใน
lineItemUpdates[x].reason
- ตั้งค่า
lineItemUpdates[x].orderState
เป็นCONFIRMED
คุณสามารถลองเรียกเก็บเงินจากเครื่องมือการชำระเงินก่อนหรือหลังส่ง AsyncOrderUpdateRequestMessage ก็ได้ตามต้องการ หากธุรกรรมล้มเหลว (อาจเป็นเพราะส่วนต่างราคาสูงเกินไป) ให้ส่ง AsyncOrderUpdateRequestMessage ที่มีการตั้งค่าต่อไปนี้ใน OrderUpdate
เพื่อแจ้งให้ Google ทราบเกี่ยวกับการดำเนินการที่ไม่สำเร็จ
- ตั้งค่า
orderState
เป็นREJECTED
- อธิบายความล้มเหลวในช่อง
label
การตรวจสอบจุดชำระเงิน
ตามที่เราได้กล่าวไว้ในขั้นตอนที่ 4: ติดตั้งใช้งานการชำระเงิน ปลายทางการจำหน่ายของคุณควรตรวจสอบCheckoutRequestMessage
ขาเข้าทุกรายการ และตอบกลับด้วย CheckoutResponseMessage
ต่อไปนี้คือตัวอย่าง CheckoutResponseMessage
สำหรับการผ่านการตรวจสอบ
กรณีการใช้งาน | วิธีติดตั้งใช้งาน |
---|---|
Use Case 1: การตรวจสอบสำเร็จ | กลับ CheckoutResponse โดยต้องมี ProposedOrder และ PaymentOptions
ProposedOrder รวมภาษี ค่าธรรมเนียม และราคารวมของรถเข็น |
{ "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": { // Represents $36.73 "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 } } } } } ] } } }
การตรวจสอบที่อยู่สำหรับจัดส่ง
ปลายทางการดำเนินการตามคำสั่งซื้อควรตรวจสอบที่อยู่สำหรับจัดส่งที่อยู่ใน CheckoutRequestMessage
แต่ละรายการ
หากมีปัญหาเกี่ยวกับที่อยู่สำหรับจัดส่ง เช่น อยู่นอกพื้นที่ให้บริการจัดส่ง CheckoutResponseMessage
ที่การจำหน่ายส่งคืนควรมี FoodOrderError
ประเภทที่เหมาะสม
กรณีการใช้งาน | วิธีติดตั้งใช้งาน |
---|---|
Use Case 1: การตรวจสอบไม่สำเร็จเนื่องจากที่อยู่สำหรับจัดส่งอยู่นอกช่วงหรือมีปัญหาเกี่ยวกับที่อยู่สำหรับจัดส่ง | แสดงผล FoodErrorExtension ที่มี FoodOrderError
ซึ่งอยู่ในประเภทข้อผิดพลาด OUT_OF_SERVICE_AREA |
{ "expectUserResponse": false, "finalResponse": { "richResponse": { "items": [ { "structuredResponse": { "error": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodErrorExtension", "foodOrderErrors": [ { "error": "OUT_OF_SERVICE_AREA", "description": "Sorry, the restaurant cannot deliver to your address." } ] } } } ] } } }
การตรวจสอบมูลค่าการสั่งซื้อขั้นต่ำ
ปลายทางการจำหน่ายควรตรวจสอบมูลค่าการสั่งซื้อขั้นต่ำของ CheckoutRequestMessage
แต่ละรายการ
หากมูลค่าการสั่งซื้อไม่ถึงเกณฑ์ CheckoutResponseMessage
ที่แสดงผลโดยการดำเนินการตามคำสั่งซื้อควรมี FoodOrderError
ของประเภทข้อผิดพลาด REQUIREMENTS_NOT_MET
กรณีการใช้งาน | วิธีติดตั้งใช้งาน |
---|---|
Use Case 1: การตรวจสอบไม่สำเร็จเนื่องจากมูลค่าการสั่งซื้อขั้นต่ำไม่ตรงตามข้อกำหนด | แสดงผล FoodErrorExtension ที่มี FoodOrderError
ของประเภทข้อผิดพลาด REQUIREMENTS_NOT_MET |
{ "expectUserResponse": false, "finalResponse": { "richResponse": { "items": [ { "structuredResponse": { "error": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodErrorExtension", "foodOrderErrors": [ { "error": "REQUIREMENTS_NOT_MET", "description": "The cart subtotal must be over $20." } ] } } } ] } } }
การตรวจสอบกรอบเวลาการสั่งซื้อ
ปลายทางการดำเนินการตามคำสั่งซื้อควรตรวจสอบปัจจัยที่อาจส่งผลต่อกรอบเวลาการสั่งซื้อของ CheckoutRequestMessage
แต่ละรายการ
ตัวอย่างเช่น หากร้านอาหารปิดอยู่หรือไม่รับคำสั่งซื้อแล้วในขณะนี้ CheckoutResponseMessage
ที่การจำหน่ายสินค้าของคุณแสดงผลควรมี FoodOrderError
ของข้อผิดพลาดประเภท CLOSED
หรือ NO_CAPACITY
ตามลำดับ
กรณีการใช้งาน | วิธีติดตั้งใช้งาน |
---|---|
Use case 1: ตรวจสอบไม่สำเร็จเนื่องจากร้านอาหารปิดอยู่หรือไม่รองรับอีกต่อไป | แสดงผล FoodErrorExtension ที่มี FoodOrderError
ของประเภทข้อผิดพลาด CLOSED |
Use Case 2: การตรวจสอบไม่สำเร็จเนื่องจากร้านอาหารไม่ว่างและไม่ได้รับคำสั่งซื้อในขณะนี้ | แสดงผล FoodErrorExtension ที่มี FoodOrderError
ของประเภทข้อผิดพลาด NO_CAPACITY |
{ "expectUserResponse": false, "finalResponse": { "richResponse": { "items": [ { "structuredResponse": { "error": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodErrorExtension", "foodOrderErrors": [ { "error": "CLOSED", "description": "The restaurant is closed." } ] } } } ] } } }
{ "expectUserResponse": false, "finalResponse": { "richResponse": { "items": [ { "structuredResponse": { "error": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodErrorExtension", "foodOrderErrors": [ { "error": "NO_CAPACITY", "description": "Sorry, the restaurant is busy at the moment." } ] } } } ] } } }
การตรวจสอบรายการในรถเข็น
ปลายทางการดำเนินการตามคำสั่งซื้อควรตรวจสอบราคาและความพร้อมจำหน่ายสินค้าในรถเข็นแต่ละรายการที่อยู่ใน CheckoutRequestMessage
หากความพร้อมจำหน่ายหรือราคามีการเปลี่ยนแปลง CheckoutResponseMessage
ที่การจำหน่ายของคุณแสดงผลควรมี FoodOrderError
ของประเภทข้อผิดพลาด AVAILABILITY_CHANGED
หรือ PRICE_CHANGED
ตามลำดับ
กรณีการใช้งาน | วิธีติดตั้งใช้งาน |
---|---|
Use Case 1: การตรวจสอบไม่สำเร็จเนื่องจากรายการเมนูและ/หรือการปรับเปลี่ยนบางอย่างไม่ถูกต้องหรือหมด | แสดงผล FoodErrorExtension ที่มี correctedProposedOrder ,
PaymentOptions และ FoodOrderError ของประเภทข้อผิดพลาด
AVAILABILITY_CHANGED คุณต้องนำรายการที่ไม่ถูกต้องออกจาก CorrectedProposedOrder |
Use Case 2: การตรวจสอบไม่สำเร็จเนื่องจากรายการเมนูและ/หรือการปรับเปลี่ยนบางอย่างไม่ถูกต้องหรือหมด รถเข็นที่แก้ไขแล้วไม่เป็นไปตามข้อกำหนดมูลค่าการสั่งซื้อขั้นต่ำอีกต่อไป | แสดงผล FoodErrorExtension ที่มี FoodOrderError รายการของข้อผิดพลาดประเภท AVAILABILITY_CHANGED และ REQUIREMENTS_NOT_MET |
Use case 3: การตรวจสอบไม่สำเร็จเนื่องจากรายการเมนูและ/หรือราคาการปรับแต่งบางรายการมีการเปลี่ยนแปลง | แสดงผล FoodErrorExtension ที่มี correctedProposedOrder ,
PaymentOptions และ FoodOrderError ของประเภทข้อผิดพลาด
PRICE_CHANGED คุณต้องอัปเดตราคาที่ล้าสมัยใน CorrectedProposedOrder |
Use case 4: การตรวจสอบไม่สำเร็จเนื่องจากรายการเมนูและ/หรือราคาการปรับแต่งบางอย่างมีการเปลี่ยนแปลง รถเข็นที่แก้ไขแล้วไม่เป็นไปตามข้อกำหนดมูลค่าการสั่งซื้อขั้นต่ำอีกต่อไป | แสดงผล FoodErrorExtension ที่มี FoodOrderError รายการของข้อผิดพลาดประเภท PRICE_CHANGED และ REQUIREMENTS_NOT_MET |
{ "expectUserResponse": false, "finalResponse": { "richResponse": { "items": [ { "structuredResponse": { "error": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodErrorExtension", "foodOrderErrors": [ { "error": "AVAILABILITY_CHANGED", "id": "sample_item_offer_id_1", "description": "The item is no longer available." }, { "error": "AVAILABILITY_CHANGED", "id": "sample_item_offer_id_2", "description": "The item is no longer available." } ], "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": "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 } } } } } ] } } }
{ "expectUserResponse": false, "finalResponse": { "richResponse": { "items": [ { "structuredResponse": { "error": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodErrorExtension", "foodOrderErrors": [ { "error": "REQUIREMENTS_NOT_MET", "description": "The cart subtotal must be over $20." }, { "error": "AVAILABILITY_CHANGED", "id": "cart_lineitem_id" "description": "cart_lineitem_id is no longer available." } ] } } } ] } } }
{ "expectUserResponse": false, "finalResponse": { "richResponse": { "items": [ { "structuredResponse": { "error": { "@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 } } } } } ] } } }
{ "expectUserResponse": false, "finalResponse": { "richResponse": { "items": [ { "structuredResponse": { "error": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodErrorExtension", "foodOrderErrors": [ { "error": "REQUIREMENTS_NOT_MET", "description": "The cart subtotal must be over $20." }, { "error": "PRICE_CHANGED", "id": "cart_lineitem_id" "description": "cart_lineitem_id price has been updated." "updatedPrice": { "currencyCode": "USD", "units": "2", "nanos": 750000000 } } ] } } } ] } } }
ส่งการตรวจสอบคำสั่งซื้อ
ตามที่เราได้กล่าวไว้ในขั้นตอนที่ 7: ใช้การสั่งซื้อที่ส่ง ปลายทางการดำเนินการตามคำสั่งซื้อของคุณควรตรวจสอบSubmitOrderRequestMessage
ขาเข้าทุกรายการ และตอบกลับด้วย SubmitOrderResponseMessage
ต่อไปนี้คือตัวอย่าง SubmitOrderResponseMessage
สำหรับการผ่านการตรวจสอบ
กรณีการใช้งาน | วิธีติดตั้งใช้งาน |
---|---|
Use Case 1: สร้างคำสั่งซื้อสำเร็จ | SubmitOrderResponseMessage ที่มีสถานะการสั่งซื้อ CREATED โดยต้องมี actionOrderId ,
userVisibleId , orderManagementActions และ
estimatedFulfillmentTime |
Use Case 2: คำสั่งซื้อถูกปฏิเสธเนื่องจากปัญหาเกี่ยวกับการชำระเงิน | SubmitOrderResponseMessage ที่มีสถานะคำสั่งซื้อ REJECTED โดยต้องมี actionOrderId ,
userVisibleId , orderManagementActions และ
rejectionInfo ประเภท PAYMENT_DECLINED |
Use Case 3: ระบบปฏิเสธคำสั่งซื้อเนื่องจากผู้ใช้ถูกแจ้งว่าถูกแบน | SubmitOrderResponseMessage ที่มีสถานะการสั่งซื้อ REJECTED โดยต้องมี actionOrderId ,
userVisibleId , orderManagementActions และ
rejectionInfo ประเภท INELIGIBLE |
Use Case 4: ระบบปฏิเสธคำสั่งซื้อเนื่องจากข้อมูลผู้ใช้ไม่สมบูรณ์หรือไม่ถูกต้อง | SubmitOrderResponseMessage ที่มีสถานะคำสั่งซื้อ REJECTED โดยต้องมี actionOrderId ,
userVisibleId , orderManagementActions และ
rejectionInfo ประเภท INELIGIBLE |
Use Case 5: คำสั่งซื้อถูกปฏิเสธโดยไม่ทราบสาเหตุ | SubmitOrderResponseMessage ที่มีสถานะคำสั่งซื้อ REJECTED โดยต้องมี actionOrderId ,
userVisibleId , orderManagementActions และ
rejectionInfo ประเภท UNKNOWN |
{ "expectUserResponse": false, "finalResponse": { "richResponse": { "items": [ { "structuredResponse": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "CREATED", "label": "Order received" }, "updateTime": "2017-05-10T02:30:00.000Z", "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", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "VIEW_DETAILS", "button": { "title": "View order", "openUrlAction": { "url": "https://orderview.partner.com?orderid=sample_action_order_id" } } } ] } } } ] } } }
{ "expectUserResponse": false, "finalResponse": { "richResponse": { "items": [ { "structuredResponse": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "REJECTED", "label": "Order rejected" }, "updateTime": "2017-05-10T02:30:00.000Z", "rejectionInfo": { "type": "PAYMENT_DECLINED", "reason": "Insufficient funds" }, "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", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "VIEW_DETAILS", "button": { "title": "View order", "openUrlAction": { "url": "https://orderview.partner.com?orderid=sample_action_order_id" } } } ] } } } ] } } }
{ "expectUserResponse": false, "finalResponse": { "richResponse": { "items": [ { "structuredResponse": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "REJECTED", "label": "Order rejected" }, "updateTime": "2017-05-10T02:30:00.000Z", "rejectionInfo": { "type": "INELIGIBLE", "reason": "Sorry, we are not able to take orders from this user" }, "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", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "VIEW_DETAILS", "button": { "title": "View order", "openUrlAction": { "url": "https://orderview.partner.com?orderid=sample_action_order_id" } } } ] } } } ] } } }
{ "expectUserResponse": false, "finalResponse": { "richResponse": { "items": [ { "structuredResponse": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "REJECTED", "label": "Order rejected" }, "updateTime": "2017-05-10T02:30:00.000Z", "rejectionInfo": { "type": "INELIGIBLE", "reason": "Sorry, the phone number must not be blank" }, "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", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "VIEW_DETAILS", "button": { "title": "View order", "openUrlAction": { "url": "https://orderview.partner.com?orderid=sample_action_order_id" } } } ] } } } ] } } }
{ "expectUserResponse": false, "finalResponse": { "richResponse": { "items": [ { "structuredResponse": { "orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "REJECTED", "label": "Order rejected" }, "updateTime": "2017-05-10T02:30:00.000Z", "rejectionInfo": { "type": "UNKNOWN", "reason": "Sorry, there is something wrong with this order." }, "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", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+16505554679" } } }, { "type": "VIEW_DETAILS", "button": { "title": "View order", "openUrlAction": { "url": "https://orderview.partner.com?orderid=sample_action_order_id" } } } ] } } } ] } } }