Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError #6

Closed
prodplug opened this issue Feb 17, 2022 · 2 comments
Closed

KeyError #6

prodplug opened this issue Feb 17, 2022 · 2 comments

Comments

@prodplug
Copy link

prodplug commented Feb 17, 2022

I am getting the following error

C:\Users\Admin\PycharmProjects\paying\main.py:57: DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in future versions. Use ConfigParser di
rectly instead.
  parser = SafeConfigParser()
No 'buyer_email' set! If you cannot obtain the buyer's email and want to handle refunds on your own you can use your own email instead.
Traceback (most recent call last):
  File "C:\Users\Admin\PycharmProjects\paying\main.py", line 97, in <module>
    bot.polling()
  File "C:\Python310\lib\site-packages\telebot\__init__.py", line 658, in polling
    self.__threaded_polling(non_stop, interval, timeout, long_polling_timeout, allowed_updates)
  File "C:\Python310\lib\site-packages\telebot\__init__.py", line 720, in __threaded_polling
    raise e
  File "C:\Python310\lib\site-packages\telebot\__init__.py", line 680, in __threaded_polling
    self.worker_pool.raise_exceptions()
  File "C:\Python310\lib\site-packages\telebot\util.py", line 135, in raise_exceptions
    raise self.exception_info
  File "C:\Python310\lib\site-packages\telebot\util.py", line 87, in run
    task(*args, **kwargs)
  File "C:\Users\Admin\PycharmProjects\paying\main.py", line 84, in r1day
    'txid': getrday['txn_id'],
KeyError: 'txn_id'



Below is my code

@bot.message_handler(content_types=["text"], func=lambda message: message.text == "🚀 1 Day")
def r1day(message):
    buyrday = {
        'amount': 50,
        'currency1': 'USD',
        'currency2': 'BTC'
    }
    client = CryptoPayments(API_KEY, API_SECRET, IPN_URL)
    getrday = client.createTransaction(buyrday)

    if getrday['error'] == 'ok':  # check error status 'ok' means the API returned with desired result
        print(getrday['amount'])  # print some values from the result
        print(getrday['address'])
        bot.send_message(message.chat.id, (getrday['amount']), (getrday['address']))
    else:
        print(getrday['error'])
        bot.send_message(message.chat.id, (getrday['error']))

        post_params1 = {
            'txid': getrday['txn_id'],
        }

        getrdayInfo = client.getTransactionInfo(post_params1)  # call coinpayments API using instance
        if getrdayInfo['error'] == 'ok':  # check error status 'ok' means the API returned with desired result
            print(getrdayInfo['amountf'])
            print(getrdayInfo['payment_address'])
            bot.send_message(message.chat.id, (getrdayInfo['amountf']), (getrdayInfo['payment_address']))
        else:
            print(getrdayInfo['error'])
            bot.send_message(message.chat.id, (getrdayInfo['error']))
@mistal-distal
Copy link
Owner

I would use Postman to send the request and verify that the request is handled properly and that the response is the same as previous CoinPayments API versions.

I'm not longer able to work/help on this project.

@mistal-distal
Copy link
Owner

@prodplug

Also it appears you're reciving an error: No 'buyer_email' set! If you cannot obtain the buyer's email and want to handle refunds on your own you can use your own email instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants