The payments are bank-to-bank account and non-recourse so they cannot be pulled back once initiated. There is no credit and fraud component.
India is not an exception and most other countries have similar structure. I think WeChat payments have a similar cost structure though I might be wrong. Most payment systems are very low cost (approaching cost of bandwidth). For comparison, FedWire can transmit payments upto 100 million and above for ~$1.20. Below $100 Million it is $0.90 ;)
UPI Statistics: https://www.npci.org.in/what-we-do/upi/product-statistics
FedWire Cost Table: https://www.frbservices.org/resources/fees/wires-2021.html
We have a bizarre system where retailers mark everything up an extra 2%, to give their more well-off customers (that pay with decent credit cards) an effective 2% discount and the ability to dispute charges.
I think retailers would love a new system with less transaction fees, but banks definitely would not, and some customers may not either if it means sacrificing their credit card rewards and perks.
People need to have cards, the cards need to have money on them - both of these are already assumptions that aren't guaranteed to hold for a lot of people.
Sure, it's possible to overcome all of these things in theory - but at what benefit to the population? Cashless payments are not a goal in and of themselves.
Also, there are taxes. Easier to dodge taxes with cash transactions than it is with a piece of plastic.
Even if you use a barcode there's no reason why the price can't be entered in directly or modified at the behest of the cashier. In the West we just don't trust our cashiers enough to do that sort of thing so we lock out that power ("Manager assistance needed at isle four!").
What the world needs right now is cashless payments that don't have absurd (>0.1%) transaction fees. I used to work at First Data (largest credit card processor) and you know how much it costs them to execute a credit card transaction? NOTHING. It's literally nothing.
It's not even a factor of, "we have this many servers in this many data centers and here's how much the electricity costs, divided by the total number of transactions in a given day." Why? Because every customer that uses First Data still pays a monthly fee that more than makes up for the cost of all the employees, data centers, software, etc etc.
If all First Data ever collected was that monthly fee they'd still be profitable (assuming all they did was handle credit card transactions).