D
D
defany2021-04-16 15:38:32
API
defany, 2021-04-16 15:38:32

Why doesn't he send currency to a person after paying for qiwi?

I wrote a code to create a payment link and send this link to the user, the link is sent and everything works without interruption, but after payment the currency is not sent to the person. Tell me how to fix this problem?

vk.updates.hear(/^Купить/i , async (context) => {
    const lifetime = qiwiApi.getLifetimeByDay(1);
    const billId = qiwiApi.generateId();
    const balance = await myBalance() / 1000
    let qiwi_num = await context.question(`Введите кол-во рублей для покупки. \nНа данный момент доступно [ ${balance} ] коинов для покупки`)
    let qiwi_num_check = Number(qiwi_num.text)
    if (!qiwi_num_check || qiwi_num_check <= 0 || balance <= 0 || balance < qiwi_num_check) {
        context.send(
            'Ошибка при покупке',
            {
                keyboard: mainMenu,
            }
        )
        return
    }

    const fields = {
        amount: qiwi_num_check,
        currency: 'RUB',
        comment: context.senderId,
        expirationDateTime: lifetime,
    };

    qiwiApi.createBill( billId, fields ).then( data => {
        vk.api.call("utils.getShortLink", {url: `${data.payUrl}`}).then(function (res){
            context.send(res.short_url);
        })
    })

    
    context.send(`✅⚡ Вы получите [ ${utils.sp(Math.floor(qiwi_num_check) * botMoney.course)} ] коинов \n✍ После оплаты напишите "Оплачено".`)
    let pay = qiwi_num_check * botMoney.course
    if (context.message.send == 'Оплачено') {
        await qiwiApi.getBillInfo(billId).then( data => {
            if (data.status.value == 'PAID' && data.comment == context.senderId){
                payment(context.senderId , pay)
                context.send('Спасибо за оплату')
                return      
            } else {
                context.send('Вы не оплатили счет')
            }
        })
    }
})


PS The 'payment' function is used to send currency and it works fine, I checked it.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question