मेन्यू फ़ीड और ऑर्डर पूरा करने वाले कार्ट के आइटम को मैप करना
जब ग्राहक आपके मेन्यू फ़ीड से आइटम को अपने कार्ट में जोड़ते हैं और पैसे चुकाते हैं, तो Google उन आइटम को आपके ऑर्डर की कीमत और खरीदारी के लिए उपलब्ध होने की पुष्टि करने के लिए, ऑर्डर पूरा करने वाले एंडपॉइंट पर भेजता है. कीमत और उपलब्धता की पुष्टि होने के बाद, ग्राहक ऑर्डर दे सकता है. इस सेक्शन में कार्ट आइटम को पूरा करने के लिए मेन्यू फ़ीड आइटम को मैप करने का तरीका बताया गया है.
इस सेक्शन में दिए गए सैंपल, मेन्यू फ़ीड और कार्ट स्कीमा के स्ट्रिप-डाउन वर्शन हैं. सिर्फ़ वे फ़ील्ड दिखाए जाते हैं जो मेन्यू फ़ीड और कार्ट ऑब्जेक्ट के बीच मैपिंग दिखाने के लिए काम के होते हैं. पूरे स्कीमा के लिए, Menu
और Cart
देखें.
कार्ट में जोड़े गए Menu
फ़ीड में मौजूद आइटम, Cart
ऑब्जेक्ट में भेजे जाते हैं. ऐसा चेकआउट और ऑर्डर सबमिट करने, दोनों के लिए किया जाता है.
lineItems
कलेक्शन में, सामान्यMenuItem
कोLineItem
के तौर पर दिखाया जाता है. साथ ही, मेन्यू फ़ीड मेंofferId
चुने गए मेन्यू आइटम काoffer.id
होता है.- ज़रूरी
MenuItemOption
वालेMenuItem
कोlineItems
कलेक्शन मेंLineItem
के तौर पर दिखाया जाता है. इसमें मेन्यू फ़ीड से चुने गए मेन्यू आइटम के विकल्पoffer.id
के तौर परofferId
चुना गया है. LineItem
केAddOnMenuItem
कोFoodItemExtension
कीoptions
कैटगरी मेंFoodItemOption
के तौर पर दिखाया जाता है. हर विकल्प में एकofferId
होता है, जो मेन्यू फ़ीड में चुने गए ऐड-ऑन मेन्यू आइटम केoffer.id
से मेल खाता है. ध्यान दें कि किसी AddOnमेन्यूItem में भी AddOnमेन्यूItem नेस्ट किए गए ऐसे जोड़े जा सकते हैं जिन्हें हर विकल्प के अंदरsubOptions
के रूप में दिखाया जाता है.
नीचे दिए गए उदाहरण, मेन्यू फ़ीड और फ़ुलफ़िलमेंट कार्ट के बीच मेन्यू आइटम को मैप करते हैं.
JSON
इस उदाहरण में, आसान मेन्यू आइटम की सूची दी गई है.
मेन्यू फ़ीड में मौजूद मेन्यू आइटम:
{ "@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" } ] }
JSON
इस उदाहरण में, एक या उससे ज़्यादा AddOnमेन्यूआइटम वाला मेन्यू आइटम शामिल है.
मेन्यू फ़ीड में मौजूद मेन्यू आइटम:
{ "@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" } ] }
JSON
इस उदाहरण में एक मेन्यू आइटम शामिल है, जिसमें मेन्यू आइटम के विकल्प, AddOnमेन्यूआइटम, और नेस्ट किए गए AddOnमेन्यू आइटम शामिल हैं
मेन्यू फ़ीड में मौजूद मेन्यू आइटम:
{ "@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
विकल्प का इस्तेमाल किया जा सकता है जिसमें
CheckoutResponse के बजाय FoodErrorExtension
शामिल होता है. इस जवाब का इस्तेमाल, प्रोसेसिंग के दौरान हुई एक या उससे ज़्यादा गड़बड़ियों की पहचान करने के लिए किया जा सकता है.
गड़बड़ियों को ठीक करने के दो तरीके हैं:
- वापस पाई जा सकने वाली गड़बड़ियां: उपयोगकर्ता को ऑर्डर सबमिट करने के लिए, अपने कार्ट में बदलाव करने की ज़रूरत नहीं होती. उदाहरण के लिए, अगर आपको लगता है कि
Cart
में मौजूद किसी आइटम की कीमत में बदलाव हुआ है, तो इसके जवाब मेंcorrectedProposedOrder
औरpaymentOptions
के साथ-साथ,FoodOrderError
की गड़बड़ीPRICE_CHANGED
को भी दिखाया जा सकता है. Google, उपयोगकर्ता को बदलाव की सूचना देता है. हालांकि, उपयोगकर्ता कोcorrectedProposedOrder
की मदद से, इसे सबमिट करने की अनुमति देता है. उपयोगकर्ता चाहें, तो वापस जाकर अपने कार्ट में बदलाव भी कर सकते हैं. आपको नयाCheckoutRequestMessage
याSubmitOrderRequestMessage
मिलेगा. - ऐसी गड़बड़ियां जिन्हें ठीक नहीं किया जा सकता: ऑर्डर सबमिट करने से पहले, उपयोगकर्ता को अपने कार्ट में बदलाव करना पड़ता है. उदाहरण के लिए, अगर आपको लगता है कि रेस्टोरेंट बंद है, तो जवाब के तौर पर
FoodOrderError
गड़बड़ीCLOSED
दिखाई जा सकती है. Google, उपयोगकर्ता को इसकी सूचना देता है और इंटरैक्शन को नए रेस्टोरेंट में अपडेट करने के लिए मैनेज करता है. आपको एक नए कार्ट के लिए नयाCheckoutRequestMessage
मिलेगा.
आम तौर पर, कार्ट-लेवल की गड़बड़ियों को ऐसा बनाएं कि उन्हें ठीक न किया जा सके और आइटम-लेवल की गड़बड़ियों को
ठीक किया जा सके. गड़बड़ी किस तरह की है और उसके मतलब क्या हैं, इसकी पूरी सूची देखने के लिए,
FoodOrderError
देखें.
कीमत में हुए बदलावों को हैंडल करना
चेकआउट के दौरान कीमत में बदलाव
अगर आपको ग्राहक के चेकआउट अनुरोध को प्रोसेस करते समय, कीमत से जुड़ी समस्या मिलती है, तो ये काम करें:
CheckoutRequestMessage
का जवाबCheckoutResponseMessage
के साथ दें, जिसमेंFoodErrorExtension
शामिल हो, जैसा कि गड़बड़ियों को मैनेज करने के तरीके में बताया गया है.- गड़बड़ी के जवाब में, कीमत को सही वैल्यू पर अपडेट करने के लिए,
correctedProposedOrder.cart
का इस्तेमाल करें. Google को सही ऑर्डर मिलता है और वह नयाCheckoutRequestMessage
जारी कर सकता है.
चेकआउट करने के बाद, Google असली उपयोगकर्ता को ऑर्डर की पुष्टि करने वाला पेज दिखाता है.
इससे कोई फ़र्क़ नहीं पड़ता कि ProposedOrder
को बदला गया है या नहीं.
अगर प्रस्तावित ऑर्डर सही किया गया था, तो Google उपयोगकर्ता को बदलावों के बारे में बताने के लिए और चेतावनियां दिखा सकता है. अगर उपयोगकर्ता ऑर्डर देने के लिए सहमत होता है, तो उसके लिए चेकआउट का
अनुरोध नहीं करना होगा. फ़्लो, सही ProposedOrder
के साथ,
ऑर्डर सबमिट करना जारी रखता है.
हालांकि, उपयोगकर्ता कभी भी अपना इरादा बदलकर अपने कार्ट में बदलाव कर सकता है. जब
उसका कार्ट इस तरह अपडेट होता है, तो Google एक नया CheckoutRequestMessage
भेजता है.
ऑर्डर सबमिट करने के दौरान कीमत में बदलाव
अगर ऑर्डर सबमिट करने की प्रक्रिया के दौरान आपको कीमत से जुड़ी कोई समस्या मिलती है
(actions.intent.TRANSACTION_DECISION
इंटेंट ट्रिगर हुआ था), तो गड़बड़ी के साथ जवाब न दें या अपने जवाब में कीमत को अपडेट न करें. अगर SubmitOrderRequestMessage
में दी गई कीमत, संख्या या दूसरी जानकारी आपके डेटा से मेल नहीं खाती है, तो orderState
को REJECTED
पर सेट करके जवाब दें. इससे यह पता चलेगा कि ऑर्डर को, मांगे गए तरीके से नहीं दिया जा सकता.
इसके बाद, अगर ऑर्डर और पेमेंट के तरीके की जानकारी मान्य है, तो orderState
को CREATED
या CONFIRMED
पर सेट करें. साथ ही, अपने सिस्टम में ऑर्डर का आईडी दिखाने के लिए, एक actionOrderId
शामिल करें. बाद में अपडेट भेजते समय इस आईडी का इस्तेमाल करना ज़रूरी है.
अगर आप पेमेंट नहीं कर पा रहे हैं और आपने पहले ही
SubmitOrderRequestMessage
भेज दिया है, तो आपके पास
AsyncOrderUpdateRequestMessage
भेजने का विकल्प है. इसमें orderState
को REJECTED
पर सेट किया जा सकता है, ताकि उपयोगकर्ता को बताया जा सके कि ऑर्डर पूरा नहीं हो पाया है.
ऑर्डर सबमिट करने के बाद कीमत में बदलाव
अगर आपको लगता है कि प्रॉडक्ट की कीमत, ऑर्डर सबमिट करने के दौरान इस्तेमाल की गई कीमत से बदल गई है, तो आपके पास नई कीमत के साथ AsyncOrderUpdateRequestMessage
जारी करने का विकल्प है. इस बारे में, एसिंक्रोनस ऑर्डर अपडेट लागू करना लेख में बताया गया है.
एक साथ काम नहीं करने वाले ऑर्डर से जुड़े अपडेट का इस्तेमाल करके कीमतों को अपडेट करने के लिए:
lineItemUpdates[x].price
में जाकर कीमत बदलें. यह वैल्यू, आइटम की कुल लागत को दिखाती है. इसमें, ऐड-ऑन और संख्या से गुणा करने की लागत भी शामिल होती है. (ज़्यादा जानकारी के लिए,LineItem
केprice
फ़ील्ड का ब्यौरा देखें.)lineItemUpdates[x].reason
में पूरी जानकारी डालें.lineItemUpdates[x].orderState
कोCONFIRMED
पर सेट करें.
आप अपने विवेक से, AsyncOrderUpdateRequestMessage भेजने से पहले या बाद में पैसे चुकाने के तरीके से शुल्क लेने की कोशिश कर सकते हैं. अगर लेन-देन पूरा नहीं हो पाता है
(शायद कीमत में ज़्यादा अंतर होने की वजह से), तो Google को इसकी सूचना देने के लिए,
OrderUpdate
में नीचे दी गई सेटिंग के साथ AsyncOrderUpdateRequestMessage को भेजें:
orderState
कोREJECTED
पर सेट करें.label
फ़ील्ड में गड़बड़ी के बारे में बताएं.
चेकआउट की पुष्टि करना
जैसा कि चौथा चरण: चेकआउट की प्रोसेस लागू करना में बताया गया है, आपका फ़ुलफ़िलमेंट एंडपॉइंट, आने वाले हर CheckoutRequestMessage
मैसेज की पुष्टि करेगा और CheckoutResponseMessage
की मदद से जवाब देगा.
सही तरीके से पुष्टि करने के लिए, यहां CheckoutResponseMessage
का एक उदाहरण दिया गया है:
इस्तेमाल के बारे में जानकारी | लागू करने का तरीका |
---|---|
इस्तेमाल का पहला उदाहरण: पुष्टि हो गई | वापसी की तारीख: CheckoutResponse . इसमें
ProposedOrder और PaymentOptions होने चाहिए.
ProposedOrder में टैक्स, शुल्क, और कार्ट की कुल कीमत शामिल होती है. |
JSON
{ "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
शामिल होना चाहिए.
इस्तेमाल के बारे में जानकारी | लागू करने का तरीका |
---|---|
इस्तेमाल का पहला उदाहरण: डिलीवरी का पता सीमा से बाहर होने या डिलीवरी के पते में कोई समस्या होने की वजह से, पुष्टि नहीं की जा सकी | FoodOrderError
गड़बड़ी के टाइप OUT_OF_SERVICE_AREA के साथ FoodErrorExtension दें. |
JSON
{ "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
होनी चाहिए.
इस्तेमाल के बारे में जानकारी | लागू करने का तरीका |
---|---|
इस्तेमाल का पहला उदाहरण: ऑर्डर की कम से कम वैल्यू पूरी न होने की वजह से, पुष्टि नहीं की जा सकी | FoodOrderError
गड़बड़ी के टाइप REQUIREMENTS_NOT_MET के साथ FoodErrorExtension दें. |
JSON
{ "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
होनी चाहिए.
इस्तेमाल के बारे में जानकारी | लागू करने का तरीका |
---|---|
इस्तेमाल का पहला उदाहरण: पुष्टि नहीं हो सकी, क्योंकि रेस्टोरेंट बंद है या अब काम नहीं करता | FoodOrderError
गड़बड़ी के टाइप CLOSED के साथ FoodErrorExtension दें. |
इस्तेमाल का दूसरा उदाहरण: पुष्टि नहीं हो सकी, क्योंकि रेस्टोरेंट व्यस्त है और फ़िलहाल ऑर्डर नहीं ले रहा है | FoodOrderError
गड़बड़ी के टाइप NO_CAPACITY के साथ FoodErrorExtension दें. |
JSON
{ "expectUserResponse": false, "finalResponse": { "richResponse": { "items": [ { "structuredResponse": { "error": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodErrorExtension", "foodOrderErrors": [ { "error": "CLOSED", "description": "The restaurant is closed." } ] } } } ] } } }
JSON
{ "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
होनी चाहिए.
इस्तेमाल के बारे में जानकारी | लागू करने का तरीका |
---|---|
इस्तेमाल का पहला उदाहरण: पुष्टि नहीं हो सकी, क्योंकि कुछ मेन्यू आइटम और/या पसंद के मुताबिक बनाए गए विकल्प मान्य नहीं हैं या स्टॉक में नहीं हैं | FoodErrorExtension को correctedProposedOrder , PaymentOptions , और FoodOrderError गड़बड़ी के टाइप
AVAILABILITY_CHANGED के साथ दिखाएं. अमान्य आइटम
CorrectedProposedOrder से हटाए जाने चाहिए. |
इस्तेमाल का दूसरा उदाहरण: पुष्टि नहीं हो सकी, क्योंकि कुछ मेन्यू आइटम और/या पसंद के मुताबिक बनाई गई चीज़ें मान्य नहीं हैं या स्टॉक में नहीं हैं. सही किया गया कार्ट अब कम से कम ऑर्डर वैल्यू की ज़रूरी शर्त को पूरा नहीं करता. | AVAILABILITY_CHANGED और REQUIREMENTS_NOT_MET
तरह की FoodOrderError
गड़बड़ी के साथ FoodErrorExtension दें. |
इस्तेमाल का तीसरा उदाहरण: पुष्टि नहीं हो सकी, क्योंकि कुछ मेन्यू आइटम और/या पसंद के मुताबिक तय की गई कीमतें बदल गई हैं | FoodErrorExtension को correctedProposedOrder , PaymentOptions , और FoodOrderError गड़बड़ी के टाइप
PRICE_CHANGED के साथ दिखाएं. पुरानी कीमतों को
CorrectedProposedOrder में अपडेट करना ज़रूरी है. |
इस्तेमाल का चौथा उदाहरण: पुष्टि नहीं हो सकी, क्योंकि कुछ मेन्यू आइटम और/या पसंद के मुताबिक तय की गई कीमतें बदल गई हैं. सही किया गया कार्ट अब कम से कम ऑर्डर वैल्यू की ज़रूरी शर्त को पूरा नहीं करता | PRICE_CHANGED और REQUIREMENTS_NOT_MET
तरह की FoodOrderError
गड़बड़ी के साथ FoodErrorExtension दें. |
JSON
{ "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 } } } } } ] } } }
JSON
{ "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." } ] } } } ] } } }
JSON
{ "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 } } } } } ] } } }
JSON
{ "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 } } ] } } } ] } } }
ऑर्डर की पुष्टि सबमिट करना
जैसा कि सातवां चरण लागू करें: ऑर्डर सबमिट करें में बताया गया है, आपका फ़ुलफ़िलमेंट एंडपॉइंट हर SubmitOrderRequestMessage
पर आने वाले हर ईमेल की पुष्टि करेगा और SubmitOrderResponseMessage
के साथ जवाब देगा.
सही तरीके से पुष्टि करने के लिए, यहां SubmitOrderResponseMessage
का एक उदाहरण दिया गया है:
इस्तेमाल के बारे में जानकारी | लागू करने का तरीका |
---|---|
इस्तेमाल का पहला उदाहरण: ऑर्डर बन गया है | CREATED ऑर्डर की स्थिति वाली SubmitOrderResponseMessage . इसमें actionOrderId ,
userVisibleId , orderManagementActions , और
estimatedFulfillmentTime होने चाहिए. |
इस्तेमाल का दूसरा उदाहरण: पैसे चुकाने की समस्याओं की वजह से ऑर्डर अस्वीकार कर दिया गया है | REJECTED ऑर्डर की स्थिति वाली SubmitOrderResponseMessage . इसमें actionOrderId ,
userVisibleId , orderManagementActions , और
rejectionInfo टाइप PAYMENT_DECLINED होना चाहिए. |
इस्तेमाल का तीसरा उदाहरण: उपयोगकर्ता के 'प्रतिबंधित' के तौर पर फ़्लैग किए जाने की वजह से, ऑर्डर को अस्वीकार कर दिया गया | REJECTED ऑर्डर
स्थिति के साथ SubmitOrderResponseMessage . इसमें actionOrderId ,
userVisibleId , orderManagementActions , और
rejectionInfo टाइप INELIGIBLE होना चाहिए. |
इस्तेमाल का चौथा उदाहरण: उपयोगकर्ता की जानकारी अधूरी या अमान्य होने की वजह से ऑर्डर अस्वीकार कर दिया गया | REJECTED ऑर्डर की स्थिति वाली SubmitOrderResponseMessage . इसमें actionOrderId ,
userVisibleId , orderManagementActions , और
rejectionInfo टाइप INELIGIBLE होना चाहिए. |
इस्तेमाल का पांचवां उदाहरण: अज्ञात वजह से ऑर्डर को अस्वीकार कर दिया गया है | REJECTED ऑर्डर की स्थिति वाली SubmitOrderResponseMessage . इसमें actionOrderId ,
userVisibleId , orderManagementActions , और
rejectionInfo टाइप UNKNOWN होना चाहिए. |
JSON
{ "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" } } } ] } } } ] } } }
JSON
{ "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" } } } ] } } } ] } } }
JSON
{ "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" } } } ] } } } ] } } }
JSON
{ "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" } } } ] } } } ] } } }
JSON
{ "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" } } } ] } } } ] } } }