I’m asking because I’m wondering if a throwaway line of dialogue in a series was anachronistic. I assumed it was unlikely anyone used the phrase until the popularization of credit
Credit was, actually, quite popular long before the invention of credit cards. Cash transactions were common enough- if you were travelling and stopped at an inn, you were expected to pay your bill, perhaps even pay immediately for every drink. That sometimes might not be done in cash, however, because sometimes real money was not available for transactions. In places like the US frontier of the 18th c., there would be quite a lot of passing of notes, essentially IOU's. And even in early 19th c. UK, there was a great shortage of small coins: it cost more to make some of them than they were worth, and the government didn't issue enough of them. So merchants started making and issuing their own ( which are now called Conder Tokens, after a man who first began collecting them).
But even then, a very normal way to purchase something was to first have an account with the merchant. Go into a shop, buy a bottle of brandy, and the shopkeeper would write the transaction into a day book. Then she'd later copy that purchase as a debit on the ledger page with your account. Now, it's possible she might also be buying- say, apples or butter from you- and if so, there'd also be credits on your page ( and yes, a farmer might keep a ledger of his own, as well). Periodically, you'd settle accounts. The merchant would also have accounts with suppliers ( say, someone who imported that brandy from France-) and so there would be another set of ledgers, accounts to be settled.
That changed, however with vertical integration. A man named Frank Woolworth pioneered the model of a store that sold low-cost items for a fixed price, payable in cash; the famous "5 and 10 Cent" store. Instead of a shop clerk behind the counter, fetching goods, the goods were set out on shelves in front and the customers got to select them, which saved time and expense. Manufacturing had made goods cheaper by this time, and currency was more available. By 1909 Woolworth's had gone a step further, becoming the one supplier to their own stores, buying very large lots of goods at a good price then distributing them. The business model soon became very common- became the norm for chain stores of all kinds. So, in, say, 1920 Liverpool, there would be plenty of businesses who did not sell on account, would be "cash only".