async def on_chat_message(msg): content_type, chat_type, chat_id = amanobot.glance(msg) print(content_type, chat_type, chat_id) if content_type != 'successful_payment': sent = await bot.sendInvoice( chat_id, "Nick's Hand Cream", "Keep a man's hand like a woman's", payload='a-string-identifying-related-payment-messages-tuvwxyz', provider_token=PAYMENT_PROVIDER_TOKEN, start_parameter='abc', currency='HKD', prices=[ LabeledPrice(label='One Case', amount=987), LabeledPrice(label='Package', amount=12) ], need_shipping_address=True, is_flexible=True) # required for shipping query # 'Pay' button appears automatically pprint(sent) print(Invoice(**sent['invoice'])) else: print('Successful payment RECEIVED!!!') pprint(msg) print(SuccessfulPayment(**msg['successful_payment']))
async def on_shipping_query(self, msg): query_id, from_id, invoice_payload = amanobot.glance( msg, flavor='shipping_query') print('Shipping query:') pprint(msg) await bot.answerShippingQuery( query_id, True, shipping_options=[ ShippingOption(id='fedex', title='FedEx', prices=[ LabeledPrice(label='Local', amount=345), LabeledPrice(label='International', amount=2345) ]), ShippingOption(id='dhl', title='DHL', prices=[ LabeledPrice(label='Local', amount=342), LabeledPrice(label='International', amount=1234) ]) ])
def send_invoice(seed_tuple): msg = seed_tuple[1] content_type, chat_type, chat_id = amanobot.glance(msg) if content_type == 'text': sent = bot.sendInvoice( chat_id, "Nick's Hand Cream", "Keep a man's hand like a woman's", payload='a-string-identifying-related-payment-messages-tuvwxyz', provider_token=PAYMENT_PROVIDER_TOKEN, start_parameter='abc', currency='HKD', prices=[ LabeledPrice(label='One Case', amount=987), LabeledPrice(label='Package', amount=12)], need_shipping_address=True, is_flexible=True) # required for shipping query print('Invoice sent:') pprint(sent)