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
}
I get an error when trying to respond to an event "pre_checkout_query".
My Code
My Error
And I see strange code in your library, maybe it's a typo. Or am I misapplying your library