I worked in F&I for a few years at both a Ford and a Hyundai dealer.
I would never, ever, ever buy from a dealer that charges more to pay cash or ties financing as a condition to buy. Why? That dealer does not see the big picture, does not understand the laws of averages, and does not want to build long term customer loyalty. Dealers that do that are merely chasing month end, not business over the long term. That likely means the used cars are not reconditioned as well (lipstick on a pig) and may not have been top rated inventory at auction. In other words, a sign you are dealing with Herb Tarlek and his bad suits.
In my experience the loan origination fee (aka commission) was paid once the money was forwarded to the dealer by the bank. Lenders use volume and rates to compensate for the extremely small number of loans that get paid off instantly or within 90 days. From my days working in dealers, this was less than 1%, vs 4-5% loans that go delinquent that banks also lose (more) money on.
This is partially why rates on used cars are higher. They are, in fact, lower risk loans as the car depreciates less (all things being equal otherwise - same borrower, same income etc) but there is a small amount factored into every loan to compensate for the ones they don't make money off, either via very early payout or delinquency. The same is true for new cars, but since most are financed via the manufacturer, it is a different animal altogether.
Also remember the bank makes the MOST money at the beginning of the loan, as the interest-principal ratio is much higher.
The long and short is this - dealers make money financing cars no matter what. Most make the equivalent of 1-2 months of payments as a fee, depending on loan amount and amortization.
Auto finance companies themselves (aka Ford Credit, Toyota Credit) do hold back a percentage of the commission for 90-120 days, but the dealers still get some regardless. But, that generally only affects new cars, and very few new cars are sold without financing due to price and incentives to finance.