Well, many spells have a material cost, ie: specific materials required to make the spells work. These spells have a book value for most of them. I have at times allowed players to pay pure gold to substitute these costs. Econmically, there's no difference. Players need to buy less and sell more while in town, best solution to that is to have merchants pay lower rates and require more in trade. 10% of book cost, maybe 25% if you're generous. But it's a great way to burn excess gold and put the crimp on players who at certain levels, may be able to buy whole castles (which is less of a problem now than it was).
Anyway, it's about as much work as determining if the rare magical items they need are in stock in town. So that's all I do: use item cost to determine how much gold is required to substitute for the items. Adjust as necessary till you get the balance you're looking for.
As an addendum, spells themselves have a transcription cost, 50gp x spell level. If you want to allow your casters to have emergency slots, you could let them burn 50gp per spell level for any spells beyond what they can cast.
As an aside: you'll need to run the variant rules for wish, which will put the brakes on the party generating infinite money.