How to confirm that a bitcoin transaction is confirmed and success?
Bitcoin transactions do not have a failure state, unlike ethereum. They are either mined, or they are not.

In general, a transaction should be considered final when:


It is included in a block, let's say with block number n
There are 5 blocks after this (current height >= n+5)


You don't really even need to loop every second. You can use the zmq feature of Bitcoin Core, or one of the numerous websocket APIs, or just poll for new blocks every 10 minutes. Once you see your tx in a block, you have one confirmation. Then, you simply need to check the next blocks to make sure they build upon the block with your tx.