मेन्यू फ़ीड और फ़ुलफ़िलमेंट कार्ट आइटम को मैप करना
जब खरीदार आपके मेन्यू फ़ीड से आइटम को अपने कार्ट में जोड़ते हैं और चेक आउट करते हैं, तो Google उन आइटम की कीमत और उपलब्धता की पुष्टि करने के लिए, उन्हें आपके फ़ुलफ़िलमेंट एंडपॉइंट पर भेजता है. कीमत और उपलब्धता की पुष्टि होने के बाद, ग्राहक ऑर्डर कर सकता है. इस सेक्शन में, मेन्यू फ़ीड के आइटम को फ़ुलफ़िलमेंट कार्ट के आइटम पर मैप करने का तरीका बताया गया है.
इस सेक्शन में दिए गए सैंपल, मेन्यू फ़ीड और कार्ट स्कीमा के छोटे वर्शन हैं. मेन्यू फ़ीड और कार्ट ऑब्जेक्ट के बीच मैपिंग को दिखाने के लिए, सिर्फ़ काम के फ़ील्ड दिखाए जाते हैं. पूरे स्कीमा के लिए, Menu
और Cart
देखें.
Menu
फ़ीड में मौजूद वे आइटम जो कार्ट में जोड़े जाते हैं उन्हें चेकआउट और ऑर्डर सबमिट करने, दोनों के लिए Cart
ऑब्जेक्ट में भेजा जाता है.
- एक साधारण
MenuItem
कोlineItems
ऐरे मेंLineItem
के तौर पर दिखाया जाता है. इसमेंofferId
, मेन्यू फ़ीड में चुने गए मेन्यू आइटम काoffer.id
होता है. - ज़रूरी
MenuItemOption
के साथMenuItem
कोlineItems
कलेक्शन मेंLineItem
के तौर पर दिखाया जाता है. इसमेंofferId
, मेन्यू फ़ीड से चुने गए मेन्यू आइटम के विकल्प काoffer.id
होता है. LineItem
केAddOnMenuItem
कोFoodItemExtension
केoptions
ऐरे मेंFoodItemOption
के तौर पर दिखाया जाता है. हर विकल्प में एक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" } ] }
इस उदाहरण में, एक या उससे ज़्यादा AddOnMenuItems वाला मेन्यू आइटम है.
मेन्यू फ़ीड में मेन्यू आइटम:
{ "@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
का जवाब दिया जा सकता है. इसमें CheckoutResponse के बजाय, FoodErrorExtension
शामिल होता है. प्रोसेसिंग के दौरान हुई एक या उससे ज़्यादा गड़बड़ियों की पहचान करने के लिए, इस रिस्पॉन्स का इस्तेमाल किया जा सकता है.
गड़बड़ियों को मैनेज करने के दो तरीके हैं:
- ठीक की जा सकने वाली गड़बड़ियां: ऑर्डर सबमिट करने के लिए, उपयोगकर्ता को अपने कार्ट में बदलाव करने की ज़रूरत नहीं होती. उदाहरण के लिए, अगर आपको पता चलता है कि
Cart
में मौजूद किसी आइटम की कीमत में बदलाव हुआ है, तोcorrectedProposedOrder
औरpaymentOptions
के साथ-साथ गड़बड़ी के टाइपPRICE_CHANGED
केFoodOrderError
का इस्तेमाल करके जवाब दिया जा सकता है. Google, उपयोगकर्ता को बदलाव के बारे में बताता है, लेकिन उसेcorrectedProposedOrder
के साथ सबमिट करने की अनुमति देता है. उपयोगकर्ता चाहे, तो कार्ट पर वापस जाकर उसमें बदलाव भी कर सकता है. आपको नयाCheckoutRequestMessage
याSubmitOrderRequestMessage
मिलेगा. - ऐसी गड़बड़ियां जिन्हें ठीक नहीं किया जा सकता: ऑर्डर सबमिट करने से पहले, उपयोगकर्ता को अपने कार्ट में बदलाव करना होगा. उदाहरण के लिए, अगर आपको पता चलता है कि रेस्टोरेंट बंद है, तो गड़बड़ी के टाइप
CLOSED
के लिएFoodOrderError
का इस्तेमाल करके जवाब दिया जा सकता है. 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
भेज दिया है, तो orderState
को REJECTED
पर सेट करके AsyncOrderUpdateRequestMessage
भेजा जा सकता है. इससे उपयोगकर्ता को यह पता चलेगा कि ऑर्डर पूरा नहीं हो पाएगा.
ऑर्डर सबमिट करने के बाद कीमत में बदलाव
अगर आपको पता चलता है कि किसी प्रॉडक्ट की कीमत, ग्राहक के ऑर्डर सबमिट करने के समय कीमत से बदल गई है, तो नई कीमत के साथ 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 में टैक्स, शुल्क, और कार्ट की कुल कीमत शामिल है. |
{ "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
शामिल होना चाहिए.
इस्तेमाल का उदाहरण | लागू करने का तरीका |
---|---|
उपयोग का पहला उदाहरण: डिलीवरी का पता तय सीमा से बाहर होने या डिलीवरी पते में कोई समस्या होने की वजह से, पुष्टि नहीं हो सकी | गड़बड़ी के टाइप OUT_OF_SERVICE_AREA के FoodOrderError के साथ FoodErrorExtension दिखाएं. |
{ "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
की जानकारी होनी चाहिए.
इस्तेमाल का उदाहरण | लागू करने का तरीका |
---|---|
उपयोग का पहला उदाहरण: पुष्टि नहीं हो सकी, क्योंकि ऑर्डर की कम से कम वैल्यू पूरी नहीं हुई | गड़बड़ी के टाइप REQUIREMENTS_NOT_MET के FoodOrderError के साथ FoodErrorExtension दिखाएं. |
{ "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
में, गड़बड़ी के टाइप के तौर पर CLOSED
या NO_CAPACITY
के लिए FoodOrderError
होना चाहिए.
इस्तेमाल का उदाहरण | लागू करने का तरीका |
---|---|
उपयोग का पहला उदाहरण: रेस्टोरेंट बंद होने या अब काम न करने की वजह से पुष्टि नहीं हो सकी | गड़बड़ी के टाइप CLOSED के FoodOrderError के साथ FoodErrorExtension दिखाएं. |
उपयोग का दूसरा उदाहरण: रेस्टोरेंट में फ़िलहाल ऑर्डर नहीं लिए जा रहे हैं और वह व्यस्त है, इसलिए पुष्टि नहीं हो सकी | गड़बड़ी के टाइप NO_CAPACITY के FoodOrderError के साथ FoodErrorExtension दिखाएं. |
{ "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
होना चाहिए.
इस्तेमाल का उदाहरण | लागू करने का तरीका |
---|---|
उपयोग का पहला उदाहरण: पुष्टि नहीं हो सकी, क्योंकि मेन्यू के कुछ आइटम और/या उनके हिसाब से बनाए गए बदलाव अमान्य हैं या वे स्टॉक में नहीं हैं | FoodErrorExtension को correctedProposedOrder ,
PaymentOptions , और गड़बड़ी के टाइप के FoodOrderError के साथ दिखाएं, जो कि
AVAILABILITY_CHANGED है. अमान्य आइटम को
CorrectedProposedOrder से हटाना होगा. |
उपयोग का दूसरा उदाहरण: पुष्टि नहीं हो सकी, क्योंकि मेन्यू के कुछ आइटम और/या उनके हिसाब से बनाए गए बदलाव अमान्य हैं या वे स्टॉक में नहीं हैं. ठीक किया गया कार्ट अब ऑर्डर की कम से कम वैल्यू की ज़रूरी शर्त को पूरा नहीं करता. | गड़बड़ी के टाइप AVAILABILITY_CHANGED और
REQUIREMENTS_NOT_MET के FoodOrderError के साथ FoodErrorExtension दिखाएं. |
तीसरा उदाहरण: पुष्टि नहीं हो सकी, क्योंकि मेन्यू के कुछ आइटम और/या पसंद के मुताबिक बनाने की कीमतें बदल गई हैं | FoodErrorExtension को correctedProposedOrder ,
PaymentOptions , और गड़बड़ी के टाइप के FoodOrderError के साथ दिखाएं, जो कि
PRICE_CHANGED है. पुरानी कीमतों को CorrectedProposedOrder में अपडेट करना ज़रूरी है. |
उपयोग का उदाहरण 4: पुष्टि नहीं हो सकी, क्योंकि मेन्यू के कुछ आइटम और/या पसंद के मुताबिक बनाने की कीमतें बदल गई हैं. बदले गए कार्ट में, ऑर्डर की कम से कम वैल्यू की ज़रूरी शर्तें पूरी नहीं होतीं | गड़बड़ी के टाइप PRICE_CHANGED और
REQUIREMENTS_NOT_MET के FoodOrderError के साथ FoodErrorExtension दिखाएं. |
{ "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 } } ] } } } ] } } }
ऑर्डर की पुष्टि करने के लिए सबमिट करें
सातवां चरण: ऑर्डर सबमिट करने की सुविधा लागू करना में बताए गए तरीके के मुताबिक, आपके ऑर्डर फ़ुलफ़िल करने वाले एंडपॉइंट को हर बार आने वाले SubmitOrderRequestMessage
की पुष्टि करनी चाहिए और SubmitOrderResponseMessage
के साथ जवाब देना चाहिए.
पुष्टि होने पर दिखने वाले SubmitOrderResponseMessage
का एक उदाहरण यहां दिया गया है:
इस्तेमाल का उदाहरण | लागू करने का तरीका |
---|---|
इस्तेमाल का पहला उदाहरण: ऑर्डर पूरा हो गया | CREATED ऑर्डर की स्थिति वाला SubmitOrderResponseMessage . इसमें actionOrderId ,
userVisibleId , orderManagementActions , और
estimatedFulfillmentTime होने चाहिए. |
इस्तेमाल का दूसरा उदाहरण: पेमेंट से जुड़ी समस्याओं की वजह से ऑर्डर अस्वीकार कर दिया गया | REJECTED ऑर्डर की स्थिति वाला SubmitOrderResponseMessage . इसमें PAYMENT_DECLINED टाइप के actionOrderId ,
userVisibleId , orderManagementActions , और
rejectionInfo होने चाहिए. |
इस्तेमाल का तीसरा उदाहरण: उपयोगकर्ता को पाबंदी वाले के तौर पर फ़्लैग किया गया है, इसलिए ऑर्डर अस्वीकार कर दिया गया है | REJECTED ऑर्डर की स्थिति वाला SubmitOrderResponseMessage . इसमें INELIGIBLE टाइप के actionOrderId ,
userVisibleId , orderManagementActions , और
rejectionInfo होने चाहिए. |
इस्तेमाल का उदाहरण 4: ऑर्डर अस्वीकार किया गया, क्योंकि उपयोगकर्ता की जानकारी अधूरी या अमान्य है | REJECTED ऑर्डर की स्थिति वाला SubmitOrderResponseMessage . इसमें INELIGIBLE टाइप के actionOrderId ,
userVisibleId , orderManagementActions , और
rejectionInfo होने चाहिए. |
इस्तेमाल का पांचवां उदाहरण: किसी अज्ञात वजह से ऑर्डर अस्वीकार कर दिया गया | REJECTED ऑर्डर की स्थिति वाला SubmitOrderResponseMessage . इसमें UNKNOWN टाइप के actionOrderId ,
userVisibleId , orderManagementActions , और
rejectionInfo होने चाहिए. |
{ "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" } } } ] } } } ] } } }