Typically you would pay for it out of grant money. So Dr. Smith doesn’t pay the APC, Stanvard University doesn’t pay, the NSF pays. Or to cut a long story short, the taxpayer.
The funny thing is taxpayers ripped twice, on publishing and on access to the science and the profit goes to publication industry (not universities, research institution).
If you summarize the cash flow, the publishing industry charges twice the taxpayers in addition to the science worker and research institutions costs. If you want to make your article open access, then you pay extra fees and nowadays, the university funds ripped off twice: they still bear the cost of pay-wall publishers and open access. Long story short, the whole system is rigged in favor of gatekeepers. You may check this video[1]