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

answerPreCheckoutQuery #50

Open
iwdok opened this issue Apr 18, 2021 · 0 comments · May be fixed by #51
Open

answerPreCheckoutQuery #50

iwdok opened this issue Apr 18, 2021 · 0 comments · May be fixed by #51

Comments

@iwdok
Copy link

iwdok commented Apr 18, 2021

I get an error when trying to respond to an event "pre_checkout_query".

My Code

slimbot.on('pre_checkout_query', async payment => {
    console.log(payment);
    if (payment.invoice_payload.includes('pay')){
        let user = await database.select('*').from('users').where({telegram_id: payment.from.id});
        if (user.length === 0){
            slimbot.answerPreCheckoutQuery(payment.id, true);
        } else {
            slimbot.answerPreCheckoutQuery(payment.id, false, 'Ошибка оплаты, обратитьсе в поддержку бота');
        }
    } else {
        slimbot.answerPreCheckoutQuery(payment.id, false, 'Ошибка оплаты, обратитьсе в поддержку бота');
    }
});

My Error

D:\Рабочий стол\auto-bot\node_modules\slimbot\src\telegram.js:1241
    return this._request('answerShippingQuery', params, callback);
                                                        ^

ReferenceError: callback is not defined
    at Slimbot.answerPreCheckoutQuery (D:\Рабочий стол\auto-bot\node_modules\slimbot\src\telegram.js:1241:57)
    at Slimbot.<anonymous> (file:///D:/%D0%A0%D0%B0%D0%B1%D0%BE%D1%87%D0%B8%D0%B9%20%D1%81%D1%82%D0%BE%D0%BB/auto-bot/app.js:69:21)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)

And I see strange code in your library, maybe it's a typo. Or am I misapplying your library

answerPreCheckoutQuery(preCheckoutQueryId, ok, errorMessage) {
   let params = {
     pre_checkout_query_id: preCheckoutQueryId,
     ok: ok,
     error_message: errorMessage
   };

   return this._request('answerShippingQuery', params, callback); // On this line answer is not answerPreCheckoutQuery
 }
iwdok added a commit to iwdok/slimbot that referenced this issue Apr 21, 2021
…ned the wrong callback.

Bug fixes:
return this._request ('answerShippingQuery', params, callback);
                                                        ^
ReferenceError: callback is not defined

Fix edisonchee#50
@iwdok iwdok linked a pull request Apr 21, 2021 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant