[Python] Eror Sending Telegram Gift: RPCError 400: PAYMENT_REQUIRED (caused by...

Discussão em 'Python' iniciado por Stack, Julho 9, 2025.

  1. Stack

    Stack Membro Participativo

    I'm writing a function that takes as input the tg session (client), to_user (InputPeer) and gift (the gift we are sending) and sends the corresponding gift to the user to_user from the client account

    the following code

    async def send_gift(client, to_user, gift):
    try:
    result = await client(TransferStarGiftRequest(
    stargift=InputSavedStarGiftUser(msg_id=gift['msg_id']),
    to_id=to_user
    ))
    return True
    except Exception as e:
    error_message = str(e)
    print(f"Ошибка при отправке подарка: {error_message}")
    return False, error_message


    throws an error

    RPCError 400: PAYMENT_REQUIRED (caused by TransferStarGiftRequest)


    But there are enough stars on the account, and the gift is not in the trade ban

    p.s. to_user we get like this:

    to_user = await client.get_input_entity(user_id)


    gift is fed to the input as a dictionary from an already parsed set of gifts

    saved = await client(GetSavedStarGiftsRequest(
    peer=InputPeerSelf(),
    offset='0',
    limit=100
    ))


    and the gift looks like {'msg_id': 904312, 'title': 'Desk Calendar', 'slug': 'DeskCalendar-29932'}

    literally a week ago a similar function worked properly, but now it gives the error PAYMENT_REQUIRED, despite the fact that I have enough stars on my account

    here https://docs.telethon.dev/en/stable/concepts/errors.html you can find errors like RPCError in Telethon, but I didn’t find any information about this error specifically

    Continue reading...

Compartilhe esta Página