A
A
albus1232021-12-13 13:11:24
Python
albus123, 2021-12-13 13:11:24

Telegram bot sends purchase messages to only one user. How to decide?

When a user (other than the creator) sends a request to purchase a product (he gave an example of one of the products in the cycle (53z)), this invoice does not go to correspondence with the user, but to correspondence with the creator (i.e. me)

<b>
elif call.data == 'punkt3':
         keyboard1h = InlineKeyboardMarkup(row_width=2)
         key_30r_kurs = InlineKeyboardButton(
                text='name',
                callback_data='53z')
            keyboard1h.add(key_30r_kurs)
elif call.data == '53z':
            bot.send_invoice(message.chat.id,  #сам инвойс
                             title='name',
                             description='  ',
                             provider_token=provider_token,
                             currency='rub',
                             photo_url='',
                             photo_height=512,  # !=0/None or picture won't be shown
                             photo_width=512,
                             photo_size=512,
                             is_flexible=False, 
                             prices=[LabeledPrice('name', 299000)],
                             start_parameter='service',
                             invoice_payload='payment')
@bot.pre_checkout_query_handler(func=lambda query: True)
            def checkout(pre_checkout_query):
                bot.answer_pre_checkout_query(pre_checkout_query.id, ok=True,
                                              error_message="Оплата не прошла - попробуйте, пожалуйста, еще раз,")

     
            @bot.message_handler(content_types=['successful_payment'])
            def got_payment(message):
                bot.send_message(message.chat.id,
                                 'Ваш заказ был успешным!''Будем рады снова Вас увидеть в нашем телеграм-боте!',
                                 parse_mode='Markdown')


bot.infinity_polling(skip_pending = True)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yan White, 2021-12-13
@YanWhite1017

Maybe, the code of the 53z callback itself?

A
ambal245, 2021-12-16
@ambal245

There may be an error in the recipient's id. If a response is sent from a chat (channel), then you need to use from.id instead of chat.id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question