def send_receipt(recipient): receipt_id = "order1357" element = Template.ReceiptElement(title="Oculus Rift", subtitle="Includes: headset, sensor, remote", quantity=1, price=599.00, currency="USD", image_url=CONFIG['SERVER_URL'] + "/assets/riftsq.png" ) address = Template.ReceiptAddress(street_1="1 Hacker Way", street_2="", city="Menlo Park", postal_code="94025", state="CA", country="US") summary = Template.ReceiptSummary(subtotal=698.99, shipping_cost=20.00, total_tax=57.67, total_cost=626.66) adjustment = Template.ReceiptAdjustment(name="New Customer Discount", amount=-50) page.send(recipient, Template.Receipt(recipient_name='Peter Chang', order_number=receipt_id, currency='USD', payment_method='Visa 1234', timestamp="1428444852", elements=[element], address=address, summary=summary, adjustments=[adjustment]))
def receipts(payload, event): for i in previous_orders: element = Template.ReceiptElement(title=i['title'], subtitle=i['subtitle'], quantity=i['quantity'], price=200, currency="USD", image_url=i['image_url']) address = Template.ReceiptAddress(street_1=i['street_1'], street_2=i['street_2'], city=i['city'], postal_code=i['postal_code'], state=i['state'], country=i['country']) summary = Template.ReceiptSummary(subtotal=200, shipping_cost=5, total_tax=10, total_cost=215) adjustment = Template.ReceiptAdjustment(name=i['name'], amount=1308) page.send( event.sender_id, Template.Receipt(recipient_name=i['receipt_name'], order_number=i['order_number'], currency="USD", payment_method='visa', timestamp="1428444852", elements=[element], address=address, summary=summary, adjustments=[adjustment]))
def send_receipt(recipient): text = "Here's your recipt 👇" receipt_id = "order1357" element = Template.ReceiptElement( title="Hotel Room", subtitle="Includes: Bed, Breakfast and Board", quantity=1, price=75.00, currency="USD", image_url= "http://www.vhotel.sg/Bencoolen/scripts/images/accomodations/rooms/b_twin_display.jpg" ) summary = Template.ReceiptSummary(subtotal=78.99, total_tax=2.99, total_cost=78.99) adjustment = Template.ReceiptAdjustment(name="New Customer Discount", amount=-50) page.send(recipient, text, metadata="DEVELOPER_DEFINED_METADATA") page.send( recipient, Template.Receipt( recipient_name='Peter Chang', order_number=receipt_id, currency='USD', payment_method='Visa 1234', timestamp="1428444852", elements=[element], # address=address, summary=summary, adjustments=[adjustment])) page.send(recipient, "Would you like to continue?", quick_replies=[ QuickReply(title=("Book another room"), payload="BOOK_ANOTHER_ROOM"), QuickReply(title=("Start Again"), payload="START_AGAIN") ], metadata="DEVELOPER_DEFINED_METADATA")
def show_checkout(payload, event): product_names, product_prices, product_quantites, product_img_urls, total_price, order_id = Order.get_receipt( event.sender_id) pprint(product_names) pprint(product_prices) pprint(product_quantites) pprint(total_price) pprint(order_id) templates = [] for name, price, quantity, url in zip(product_names, product_prices, product_quantites, product_img_urls): print("npe", name, price, quantity, url) template = Template.ReceiptElement(title=name, quantity=str(quantity), price=str(price * quantity), currency="BDT", image_url=url) templates.append(template) summary = Template.ReceiptSummary(total_cost=str(total_price)) page.send( event.sender_id, Template.Receipt(recipient_name=page.get_user_profile( event.sender_id)["first_name"], summary=summary, order_number=str(order_id), currency='BDT', elements=templates)) #[elements] was wrong quick_replies = [ QuickReply("Yes", payload="CONFIRM_ORDER"), QuickReply("No", payload="DISCARD_ORDER") ] page.send(event.sender_id, "confirm order?", quick_replies=quick_replies)