pull down to refresh

Hi, I am looking for a way to check a payment in bitcoin onchain. A business wants me to implement onchain payments in his web store. The store will generate a new address (bc1q...) for every sale. Considering that. I was thinking on just verify payment by checking balance and last incoming transaction of the address, using any bitcoin api (mempool, bitcoinexplorer, etc). Is this the way to implement or is there a better way or procedure? With lightning it is easy because invoices have an amount associated, while bitcoin addresses do not force any amount for the transaction.
reply
Yes I have used that, thanks. But it would work only if I have the xpub, but I would not always have it. I will only have an empty address in some cases.
reply
Since your store generates a new address for every sale (as it should!), there will only be one incoming transaction ever. You can just check if that tx was mined. Best practice is to wait for 6 confirmations.
So I don't get what you mean with "last incoming tx". There will only be one.
But yes, you should check if the customer paid the requested amount and not less.
reply
Thanks. Yes, the "last tx..." part was just an idea only to be absolutely sure the amount in balance is coming from a recent transaction, as a secondary check. I know every xpub can generate billions of addresses in the M84/0/0/X path. But since in some cases I project to be using an exchange account (that generates different addresses) I cannot verify nor obtain the xpub they will be using. In most cases however I will be using a regular xpub so I will be sure to use a fresh address always.
reply