โปรโมชันเป็นวิธีที่คุณและ Google จะใช้เพื่อจูงใจให้ลูกค้าลองใช้บริการสั่งอาหารของคุณด้วยราคาส่วนลด Google รองรับการผสานรวมการดําเนินการตั้งแต่ต้นจนจบของคําสั่งซื้อเข้ากับระบบการจัดการโปรโมชัน
ระบบรองรับส่วนลดประเภทต่อไปนี้
- รหัสโปรโมชันที่ได้รับการสนับสนุนจาก Google: รหัสโปรโมชันที่ Google กรอกข้อมูลล่วงหน้าให้โดยอัตโนมัติหรือที่ผู้ใช้ป้อน
- รหัสโปรโมชันที่ได้รับการสนับสนุนจากบุคคลที่สาม: รหัสโปรโมชันสำหรับให้ผู้ใช้ป้อน ซึ่งบริการสั่งอาหารของคุณเป็นผู้ระบุ
- ส่วนลดอัตโนมัติที่บุคคลที่สามสนับสนุน: ส่วนลดที่บริการสั่งอาหารของคุณจะใช้โดยอัตโนมัติโดยไม่ต้องใช้รหัสโปรโมชัน
ไม่ว่าจะใช้ส่วนลดประเภทใด Google จะเรียกใช้การชำระเงินเพื่อยืนยันและนำส่วนลดไปใช้กับบริการจัดส่งอาหาร
ในฐานะนักพัฒนาบริการสั่งอาหาร คุณต้องทําการเปลี่ยนแปลงบางอย่างในการติดตั้งใช้งานเพื่อคํานวณส่วนลดสําหรับรหัสโปรโมชันที่ถูกต้อง หรือส่งข้อผิดพลาดสําหรับรหัสโปรโมชันที่ไม่ถูกต้อง จัดการข้อจํากัดในการแลกรหัสโปรโมชัน และติดตามข้อมูลการบัญชีสําหรับการจ่ายเงินชดเชย
วิธีประมวลผลโปรโมชัน
หากต้องการใช้การจำหน่ายที่รองรับโปรโมชัน ให้ทำดังนี้
- ตั้งค่าการผสานรวมโปรโมชัน (ข้ามขั้นตอนนี้หากคุณไม่ได้ใช้รหัสโปรโมชันที่ได้รับการสนับสนุนจาก Google)
- ใช้การชำระเงินที่มีโปรโมชัน
- ใช้ "ส่งคำสั่งซื้อ" ที่มีโปรโมชัน
ตั้งค่าการผสานรวมโปรโมชัน
ส่วนนี้จะอธิบายวิธีตั้งค่าการผสานรวมโปรโมชันหากคุณวางแผนที่จะใช้รหัสโปรโมชันที่ได้รับการสนับสนุนจาก Google หากต้องการรองรับเฉพาะรหัสโปรโมชันหรือส่วนลดที่บุคคลที่สามเป็นผู้สนับสนุน คุณสามารถระบุการตั้งค่าของคุณเองและข้ามส่วนนี้
Google จะระบุประเภทโปรโมชันที่จะสนับสนุนและติดต่อคุณเพื่อตั้งค่าการผสานรวม รายละเอียดที่เราให้ไว้มีดังนี้
- จำนวนส่วนลด
- มูลค่ารถเข็นขั้นต่ำ
- วันที่เริ่มต้นและวันที่สิ้นสุดของการใช้รหัสโปรโมชัน
- จำนวนเงินสูงสุดในสกุลเงินดอลลาร์ที่กำหนดงบประมาณไว้สำหรับแคมเปญโปรโมชัน
- จำนวนครั้งที่ใช้รหัสโปรโมชันได้
ตัวอย่างรหัสโปรโมชัน
FopaNewUser
: 10% (เปอร์เซ็นต์คงที่) โดยลดสูงสุด $50FopaMoreThan50
: $10 (ลดตามจำนวนเงินคงที่)
หาก Google ตัดสินใจที่จะหยุดการใช้รหัสดังกล่าว เราจะติดต่อคุณ
ตั้งค่าการจ่ายเงิน
ติดต่อที่ปรึกษา EAP ของ Google เพื่อตั้งค่าขั้นตอนการเบิกจ่าย Google จะจ่ายเงินชดเชยสำหรับธุรกรรมที่เกี่ยวข้องกับรหัสโปรโมชันที่ Google สนับสนุนก็ต่อเมื่อสถานะคำสั่งซื้อสุดท้ายตรงกับรายการใดรายการหนึ่งต่อไปนี้
CONFIRMED
IN_TRANSIT
READY_FOR_PICKUP
IN_PREPARATION
FULFILLED
ใช้การชำระเงินพร้อมโปรโมชัน
ส่วนนี้อธิบายการใช้การประมวลผลการชําระเงินเมื่อคุณรองรับรหัสโปรโมชัน (Google เป็นผู้สนับสนุนหรือบุคคลที่สามเป็นผู้สนับสนุน) สำหรับส่วนลดอัตโนมัติที่บุคคลที่สามเป็นผู้สนับสนุน คุณเพียงแค่ต้องส่งคืนบรรทัดรายการส่วนลดใน CheckoutResponseMessage
(ไม่จําเป็นต้องตรวจสอบรหัสโปรโมชัน)
ในระหว่างการดำเนินการตามคำสั่งซื้ออาหาร Google จะส่งรหัสโปรโมชันเดียวใน CheckoutRequestMessage
ไปยังการดำเนินการตามคำสั่งซื้อ ผู้ใช้อาจเปลี่ยนรถเข็นหรือรหัสโปรโมชันในคำขอชำระเงินซ้ำ
หากต้องการตรวจสอบว่าผู้ใช้ใช้รหัสโปรโมชันเป็นครั้งแรกหรือไม่ ให้ทำดังนี้
- รหัสโปรโมชันที่ได้รับการสนับสนุนจาก Google: Google จะตรวจสอบว่าผู้ใช้ที่กลับมาพยายามใช้รหัสโปรโมชันเดิมอีกครั้งหรือไม่ คุณไม่จําเป็นต้องดําเนินการใดๆ
- รหัสโปรโมชันหรือส่วนลดอัตโนมัติที่บุคคลที่สามสนับสนุน: หากยังไม่ได้ใช้การลิงก์บัญชีและการเลือกใช้ของผู้ใช้ คุณจะตรวจสอบรายละเอียดของผู้ใช้ในระหว่างการประมวลผลคำขอชำระเงินไม่ได้ แต่ให้ตรวจสอบข้อมูลนี้ขณะประมวลผล
SubmitOrderRequestMessage
โดยใช้รายละเอียดContact
(เช่น อีเมลของผู้ใช้) จากออบเจ็กต์FoodCartExtension
ระบุข้อผิดพลาดหรือคํานวณส่วนลดด้วยการดำเนินการตามคำสั่งซื้อตามคำขอชำระเงินล่าสุด เมื่อดำเนินการดังกล่าว โปรดตรวจสอบว่าระบบไม่ได้เก็บข้อมูลสถานะที่ล้าสมัยไว้
ตรวจสอบความถูกต้องของรหัสโปรโมชัน
ฝ่ายดำเนินการควรตรวจสอบความถูกต้องหรือการมีสิทธิ์ของรหัสโปรโมชันหนึ่งๆ เทียบกับข้อกำหนด เช่น วันที่หมดอายุ การใช้งานสูงสุด และส่วนลดสูงสุด จากนั้นตอบกลับอย่างเหมาะสมใน CheckoutResponseMessage
พร้อมส่วนลดที่คำนวณแล้ว หรือตอบกลับด้วย foodOrderErrors
หากใช้รหัสโปรโมชันไม่ได้ หากพบข้อผิดพลาดเกี่ยวกับรหัสโปรโมชัน ให้ทำตามกระบวนการที่อธิบายไว้ในจัดการข้อผิดพลาดเกี่ยวกับโปรโมชัน
ข้อมูลโค้ดต่อไปนี้แสดงตัวอย่าง foodOrderErrors
สำหรับรหัสโปรโมชัน
ตรวจสอบว่า correctedProposedOrder
ไม่มีโหนดโปรโมชัน
"foodOrderErrors": [
{
"error": "PROMO_NOT_APPLICABLE",
// Copy promotions.coupon string from CheckoutRequest as the ID
"id": "GoogleNewUser",
"description": "Promotion could not be applied"
}
],
"correctedProposedOrder": {// required ...},
"paymentOptions": {// required ...}
คำนวณส่วนลด
หากรหัสโปรโมชันถูกต้อง ฝ่ายดำเนินการควรคำนวณมูลค่าส่วนลดเป็นดอลลาร์และส่ง CheckoutResponseMessage
กลับพร้อมมูลค่าส่วนลดที่คำนวณแล้วในอาร์เรย์ otherItems
ราคารวมของคำสั่งซื้อต้องไม่ติดลบ หากจำนวนเงินส่วนลดเกินจากจำนวนเงินในรถเข็น ให้ส่งกลับจำนวนเงินสูงสุดในสกุลเงินดอลลาร์เพื่อให้ราคารวมของคำสั่งซื้อเป็น $0
ตัวอย่างข้อมูลโค้ดต่อไปนี้แสดงส่วน CheckoutResponseMessage
สำหรับส่วนลดโปรโมชัน
"proposedOrder": {
"otherItems": [
. . .
{
"name": "Discount",
// copy promotions.coupon field from CheckoutRequest as the id
"id": "GoogleNewUser",
"price": {
"type": "ESTIMATE",
"amount": {
"currencyCode": "USD",
"units": "-3",
"nanos": -500000000
}
},
"type": "DISCOUNT",
}
]
}
ปล่อยโปรโมชันที่ไม่ได้ใช้
คำขอชำระเงินบางรายการไม่ได้นำไปสู่การส่งคำขอสั่งซื้อ หากฝ่ายดำเนินการของคุณระงับโปรโมชันไว้ชั่วคราวเมื่อถึงเวลาเรียกเก็บเงิน ให้ตรวจสอบว่าคุณมีกลไกในการยกเลิกการระงับหากไม่มีการอ้างสิทธิ์โปรโมชันผ่าน "ส่งคำสั่งซื้อ" หลังจากผ่านไประยะเวลาหนึ่ง วิธีนี้ช่วยให้มั่นใจว่าบริการสั่งอาหารของคุณจะมีโควต้าแคมเปญที่ถูกต้อง
จัดการข้อผิดพลาดเกี่ยวกับโปรโมชัน
หากฝ่ายดำเนินการของคุณพิจารณาว่ารหัสโปรโมชันจาก CheckoutRequestMessage
ไม่ถูกต้อง (เช่น หมดอายุ ไม่ถูกต้อง หรือระบบไม่รู้จัก) ให้ส่ง CheckoutResponseMessage
ที่มี foodOrderError
ซึ่งมีรหัสข้อผิดพลาดและข้อความเหตุผลที่เกี่ยวข้อง พร้อมด้วยออบเจ็กต์ correctedProposedOrder
และ paymentOptions
หากฝ่ายดำเนินการพบข้อผิดพลาดเกี่ยวกับรหัสโปรโมชันหลายรายการจากคำขอเดียวกัน ให้ส่งข้อผิดพลาดที่กู้คืนไม่ได้กลับมาก่อนส่งข้อผิดพลาดที่กู้คืนได้ จัดลําดับความสําคัญของการตรวจสอบดังนี้ (จากความสําคัญสูงไปต่ำ)
PROMO_NOT_RECOGNIZED
PROMO_EXPIRED
PROMO_USER_INELIGIBLE
PROMO_ORDER_INELIGIBLE
PROMO_NOT_APPLICABLE
ตัวอย่าง
ต่อไปนี้คือตัวอย่างคำขอชำระเงินที่มีรหัสโปรโมชัน
{ "accessToken": "test_access_token", "lastSeen": "2018-06-22T19:25:39Z" }, "conversation": { "conversationId": "XYZ" }, "inputs": [ { "intent": "actions.foodordering.intent.CHECKOUT", "arguments": [ { "extension": { "@type": "type.googleapis.com/google.actions.v2.orders.Cart", "merchant": { "id": "https://www.exampleprovider.com/merchant/id1", "name": "Falafel Bite" }, "lineItems": [ { "name": "Falafel Tray", "type": "REGULAR", "id": "sample_item_offer_id_1", "quantity": 1, "price": { "type": "ESTIMATE", "amount": { "currencyCode": "USD", "units": "9", "nanos": 950000000 } }, "offerId": "https://www.exampleprovider.com/menu/item/offer/id1", "extension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension" } } ], "promotions": [ { "coupon": "FOPAACTIVECODE" } ], "extension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodCartExtension", "fulfillmentPreference": { "fulfillmentInfo": { "pickup": { "pickupTimeIso8601": "P0M" } } } } } } ] } ], "directActionOnly": true, "isInSandbox": true }
การตอบกลับการชำระเงินที่เกี่ยวข้องจากฝ่ายดำเนินการตามคำสั่งซื้อหากรหัสโปรโมชันถูกต้องมีดังนี้
{ "expectUserResponse": false, "finalResponse": { "richResponse": { "items": [ { "structuredResponse": { "checkoutResponse": { "proposedOrder": { "otherItems": [ { "name": "Delivery Fees", "price": { "type": "ESTIMATE", "amount": { "currencyCode": "USD", "units": "3", "nanos": 500000000 } }, "type": "DELIVERY" }, { "name": "Tax", "price": { "type": "ESTIMATE", "amount": { "currencyCode": "USD", "units": "1", "nanos": 370000000 } }, "type": "TAX" }, { "name": "Promotion", "price": { "type": "ESTIMATE", "amount": { "currencyCode": "USD", "units": "-5", "nanos": 0 } }, "id": "FOPAACTIVECODE", "type": "DISCOUNT" } ], "cart": { "merchant": { "id": "https://www.exampleprovider.com/merchant/id1", "name": "Falafel Bite" }, "lineItems": [ { "name": "Falafel Tray", "type": "REGULAR", "id": "2529103", "quantity": 1, "price": { "type": "ESTIMATE", "amount": { "currencyCode": "USD", "units": "9", "nanos": 950000000 } }, "offerId": "https://www.exampleprovider.com/menu/item/offer/id1", "extension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension" } } ], "promotions": [ { "coupon": "FOPAACTIVECODE" } ], "extension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodCartExtension", "fulfillmentPreference": { "fulfillmentInfo": { "pickup": { "pickupTimeIso8601": "P0M" } } } } }, "totalPrice": { "type": "ESTIMATE", "amount": { "currencyCode": "USD", "units": "9", "nanos": 820000000 } }, "extension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderExtension", "availableFulfillmentOptions": [ { "fulfillmentInfo": { "pickup": { "pickupTimeIso8601": "P0M" } }, "expiresAt": "2018-06-22T19:30:52.596Z" } ] } }, "orderOptions": {}, "paymentOptions": { "googleProvidedOptions": { "tokenizationParameters": { "tokenizationType": "PAYMENT_GATEWAY", "parameters": { "gateway": "stripe", "stripe:publishableKey": "example_stripe_client_key", "stripe:version": "2017-04-06" } }, "supportedCardNetworks": [ "AMEX", "DISCOVER", "MASTERCARD", "VISA", "JCB" ], "prepaidCardDisallowed": true } } } } } ], "suggestions": [] } } }
ต่อไปนี้คือตัวอย่างการตอบกลับการชำระเงินหากรหัสโปรโมชันไม่ถูกต้อง
{ "expectUserResponse": false, "finalResponse": { "richResponse": { "items": [ { "structuredResponse": { "error": { "foodOrderErrors": [ { "error": "PROMO_NOT_RECOGNIZED", "id": "SOMEPROMO", "description": "Coupon not found" } ], "correctedProposedOrder": { "cart": { "merchant": { "id": "https://www.exampleprovider.com/merchant/id1", "name": "Falafel Bite" }, "lineItems": [ { "id": "sample_item_offer_id_4", "name": "Prawns Biryani", "type": "REGULAR", "quantity": 1, "price": { "type": "ESTIMATE", "amount": { "currencyCode": "USD", "units": "18", "nanos": 750000000 } }, "offerId": "https://www.exampleprovider.com/menu/item/offer/id4", "extension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension" } } ], "extension": { "fulfillmentPreference": { "fulfillmentInfo": { "pickup": { "pickupTimeIso8601": "P0M" } } }, "@type": "type.googleapis.com/google.actions.v2.orders.FoodCartExtension" }, "promotions": [] }, "otherItems": [ { "name": "Tax", "type": "TAX", "price": { "type": "ESTIMATE", "amount": { "currencyCode": "USD", "units": "1", "nanos": 650000000 } } } ], "termsOfServiceUrl": "https://exampleprovider.com/terms", "totalPrice": { "type": "ESTIMATE", "amount": { "currencyCode": "USD", "units": "20", "nanos": 400000000 } }, "extension": { "availableFulfillmentOptions": [ { "fulfillmentInfo": { "pickup": { "pickupTimeIso8601": "PT0M" } } } ], "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderExtension" } }, "paymentOptions": { "googleProvidedOptions": { "prepaidCardDisallowed": false, "billingAddressRequired": true, "tokenizationParameters": { "tokenizationType": "PAYMENT_GATEWAY", "parameters": { "gateway": "braintree", "braintree:apiVersion": "v1", "braintree:sdkVersion": "1.4.0", "braintree:merchantId": "example_braintree_merchant_ID", "braintree:clientKey": "example_braintree_client_key", "braintree:authorizationFingerprint": "example_braintree_fingerprint" } } } }, "@type": "type.googleapis.com/google.actions.v2.orders.FoodErrorExtension" } } } ] } } }
ใช้การส่งคำสั่งซื้อที่มีโปรโมชัน
ในการส่งการจำหน่ายสินค้า ให้ตรวจสอบว่าผู้ใช้ใช้รหัสโปรโมชันเป็นครั้งแรกหรือไม่ ในระหว่างการประมวลผล SubmitOrderRequestMessage
คุณตรวจสอบข้อมูลนี้โดยใช้รายละเอียด Contact
(เช่น อีเมลของผู้ใช้) จากออบเจ็กต์ FoodCartExtension
ได้
นอกจากนี้ คุณควรตรวจสอบอีกครั้งว่ารหัสโปรโมชันใช้ได้หรือไม่ โดยทำดังนี้
- หากรหัสใช้ได้: ยืนยันคำสั่งซื้อและทําเครื่องหมายว่าแลกคูปองแล้ว
- หากรหัสใช้ไม่ได้แล้ว ให้ปฏิเสธคำสั่งซื้อที่มีข้อผิดพลาด
PROMO_NOT_APPLICABLE
คุณสามารถระบุเหตุผลที่ปฏิเสธได้อย่างชัดเจนโดยใช้กลไกเดียวกับFoodOrderUpdateExtension
ตัวอย่าง
ต่อไปนี้เป็นตัวอย่างการส่งคำขอสั่งซื้อพร้อมโปรโมชัน
{ "conversation": { "conversationId": "example_conversation_ID" }, "inputs": [ { "intent": "actions.intent.TRANSACTION_DECISION", "arguments": [ { "transactionDecisionValue": { "order": { "finalOrder": { "cart": { "merchant": { "id": "https://www.exampleprovider.com/merchant/id1", "name": "Falafel Bite" }, "lineItems": [ { "name": "Falafel Tray", "type": "REGULAR", "id": "sample_item_offer_id_1", "quantity": 1, "price": { "type": "ESTIMATE", "amount": { "currencyCode": "USD", "units": "9", "nanos": 950000000 } }, "offerId": "https://www.exampleprovider.com/menu/item/addon/offer/id1", "extension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodItemExtension" } } ], "promotions": [ { "coupon": "FOPAACTIVECODE" } ], "extension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodCartExtension", "fulfillmentPreference": { "fulfillmentInfo": { "pickup": { "pickupTimeIso8601": "P0M" } } }, "contact": { "displayName": "Food Ordering", "email": "example.provider@gmail.com", "phoneNumber": "+19993334444", "firstName": "Food", "lastName": "Ordering" } } }, "otherItems": [ { "name": "Delivery Fees", "type": "DELIVERY", "price": { "type": "ESTIMATE", "amount": { "currencyCode": "USD", "units": "3", "nanos": 500000000 } } }, { "name": "Tax", "type": "TAX", "price": { "type": "ESTIMATE", "amount": { "currencyCode": "USD", "units": "1", "nanos": 370000000 } } }, { "name": "Promotion", "type": "DISCOUNT", "price": { "type": "ESTIMATE", "amount": { "currencyCode": "USD", "units": "-5" } }, "id": "FOPAACTIVECODE" }, { "name": "Subtotal", "type": "SUBTOTAL", "price": { "type": "ESTIMATE", "amount": { "currencyCode": "USD", "units": "9", "nanos": 950000000 } } }, { "name": "Tip", "type": "GRATUITY", "price": { "type": "ESTIMATE", "amount": { "currencyCode": "USD" } } } ], "totalPrice": { "type": "ESTIMATE", "amount": { "currencyCode": "USD", "units": "9", "nanos": 820000000 } }, "extension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderExtension" } }, "googleOrderId": "example_google_order_ID", "orderDate": "2018-06-22T19:30:59.502Z", "paymentInfo": { "displayName": "example_display_name", "googleProvidedPaymentInstrument": { "instrumentToken": "example_instrument_token" }, "paymentType": "PAYMENT_CARD" }, "locale": "en" } } } ] } ], "directActionOnly": true, "isInSandbox": true }
ต่อไปนี้คือตัวอย่างการตอบกลับคำสั่งซื้อที่ส่งที่เกี่ยวข้องจากฝ่ายดำเนินการหากรหัสโปรโมชันถูกต้อง
{ "expectUserResponse": false, "finalResponse": { "richResponse": { "items": [ { "structuredResponse": { "orderUpdate": { "actionOrderId": "example_action_order_ID", "orderState": { "state": "CREATED", "label": "Order is created with partner." }, "updateTime": "2018-06-22T19:31:01.556Z", "orderManagementActions": [ { "type": "CALL_RESTAURANT", "button": { "title": "Call Us", "openUrlAction": { "url": "tel:+1-111-111-1111" } } }, { "type": "EMAIL", "button": { "title": "Email Us", "openUrlAction": { "url": "mailto:example.provider@gmail.com" } } }, { "type": "CUSTOMER_SERVICE", "button": { "title": "Customer Service", "openUrlAction": { "url": "http://www.google.com" } } } ] } } } ], "suggestions": [] } } }
ต่อไปนี้คือตัวอย่างการตอบกลับการส่งคำสั่งซื้อหากรหัสโปรโมชันไม่ถูกต้อง
"orderUpdate": { "actionOrderId": "sample_action_order_id", "orderState": { "state": "REJECTED", "label": "Order rejected." }, "updateTime": "2017-05-10T02:30:00.000Z", "rejectionInfo": { "type": "PROMO_NOT_APPLICABLE", "reason": "Sorry, there's something wrong. Try another code?" }, "orderManagementActions": [ { "type": "CUSTOMER_SERVICE", "button": { "title": "Contact customer service", "openUrlAction": { "url": "mailto:support@example.com" } } }, { "type": "EMAIL", "button": { "title": "Email restaurant", "openUrlAction": { "url": "mailto:example.provider@example.com" } } }, { "type": "CALL_RESTAURANT", "button": { "title": "Call restaurant", "openUrlAction": { "url": "tel:+19993334444" } } } ], "infoExtension": { "@type": "type.googleapis.com/google.actions.v2.orders.FoodOrderUpdateExtension", "foodOrderErrors": [ { "error": "PROMO_USER_INELIGIBLE", "description": "Sorry, you can only use this promotion once." } ] } }