E
E
ExeneS2019-09-17 13:18:32
API
ExeneS, 2019-09-17 13:18:32

I can't figure out how to check a transaction not through a file?

There is a telegram bot script where the balance replenishment is checked through comments in. After replenishment, the transaction number is written to the transactions. The problem is that the hosting does not allow files to be changed after uploading. And now help to redo the replenishment check without a file. Qiwi api using Here is the code

setInterval(async () => {
  wallet.getOperationHistory({
    rows: 1,
    operation: "IN"
  }, async (err, res) => {
    res.data.map(async (operation) => {
      if(transactions.indexOf(operation.txnId) !== -1) return;

      if(!operation.comment) return;
      if(!operation.comment.startsWith("promotions")) return;

      let user = await User.findOne({ id: Number(operation.comment.split("promotions")[1]) });
      if(!user) return;

      await user.inc("balance", operation.sum.amount);
      await user.set("verify", true);
      
      bot.sendMessage(user.id, Вы пополнили свой баланс на ${operation.sum.amount}р);

      transactions.push(operation.txnId);
      require("fs").writeFileSync("./transactions.json", JSON.stringify(transactions, null, "\t"));
    });
  });
}, 30000);

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