Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from telebot import types
- import settings
- def register_payments_command(bot):
- @bot.message_handler(commands=["comprar"])
- def show_buy_button(message):
- keyboard = types.InlineKeyboardMarkup()
- buy_button = types.InlineKeyboardButton("COMPRAR PARTICIPACIÓN", callback_data="comprar")
- keyboard.add(buy_button)
- bot.send_message(message.chat.id, "¿Quieres una participación?", reply_markup=keyboard)
- @bot.callback_query_handler(func=lambda call: call.data == "comprar")
- def callback_buy(call):
- product_price = types.LabeledPrice(label="Participación", amount=500)
- bot.send_invoice(
- chat_id=call.message.chat.id,
- title="Participación",
- description="Participación en el sorteo",
- invoice_payload="custom-paylooad-buy-product",
- provider_token=settings.STRIPE_TEST_TOKEN,
- currency="eur",
- prices=[product_price],
- start_parameter="product-purchase",
- )
- @bot.pre_checkout_query_handler(func=lambda query: True)
- def checkout_process(pre_checkout_query):
- bot.answer_pre_checkout_query(pre_checkout_query.id, ok=True)
- @bot.message_handler(content_types=["successful_payment"])
- def got_payment(message):
- bot.send_message(message.chat.id, "Gracias por participar y suerte en el sorteo!")
Advertisement
Add Comment
Please, Sign In to add comment