This doesn’t directly solve the problem, but it’s close: Discourse Subscriptions
Ignoring possible legal issues, there are existing online subscription services that could likely be used to meet the OP’s requirements with little to no code. For example, a service like Zapier could act as the intermediary between a subscription service and a Discourse forum. It could add and remove users from Discourse groups based on their subscriptions.
I’m sure it could also be accomplished with Discourse/WordPress integration and a bit of custom development.
From looking into this myself, it seems that potential legal issues might be more of a stumbling block than the the technical challenges of managing group memberships based on paid subscriptions. The organizations that I’m aware of that that are doing this kind of thing now (Youtube, Paetron, Substack, X/Twitter) likely have good legal teams.
I’m unsure about the philosophical objections to monetizing access to groups/categories.