How to sell credits as products, using commerce module?
Have a look at the Commerce Userpoints* project. It allows to buy things using userpoints and there is also a feature that allows to buy userpoints that is based on a custom product type and rules, so fully customizable.

It most likely doesn't everything that you need, but it might be a start.

There is also Commerce credits and more similar projects, but I haven't tried them out, no idea what exactly they do and how well they work.

*Disclaimer: I am the maintainer of the Userpoints project and I was also involved in that project and still have some code lying around to re-work the UI and improve it.