Note that retail pricing is an unreliable indication of actual cost to consumers. They jack it up so that they various plans can claim huge discount policies. Some of these plans are free, so there's very few people who are paying this "retail" price.
The pill makers get paid by the consumers and, in most cases, by the plan-owners. And such agreements are made exceedingly complicated. IMO, only to make them more opaque and more difficult to regulate.
Unfortunately, such a system is highly regressive as the richest tend to have the best plans, the poorest tend to have a meager plan, and the transient have no plan other than showing up at a hospital.