Can a customer buy units or credits, then use them to buy or products?

We sell reservations to classes. One class might cost 1 credit and another class might be 2 or 3 credits. Let’s say we charge $10 for each credit. Can we set up an option where a customer buys a package of credits at a discount (like 20 credits for $180 instead of $200) that the customer can use at their leisure in the future?

We’re you able to figure this out? Looking to do the same thing but haven’t been able to find anything…