Where? In the U.S.? Whenever I have paid for gas with cash or from the cashier, I pay for it in advance, “Give me $10 of regular unleaded!”
Many service stations in Canada still operate this way.
I think “everywhere in the world except the US” is probably right. I live in a major city in the UK and did it last week.
Before the 2008 Great Recession, most gas stations around me allowed people to pump then pay cash. After some stories of people driving off without paying, the stations changed their policies.
It also works like that at manned stations in France, but there are few.