How can I sell virtual codes, like for steam and origin games on magento?
I would say that this will depend if the codes you are selling are unique.
If you want to sell a virtual code, and it's exactly the same code for each person purchasing it, then you could use a downloadable product to accomplish this. The downloadable product would have a PDF or text file that would contain the code.
That could be accomplished without any modification to Magento.
If you wish to sell unique codes - so that each user purchasing a product then gets a unique code - you would have to create an extension that will handle this added functionality.
You could either have the system generate the keys on the fly as each product is purchased, or you can have a big list of unused keys that were generated elsewhere but stored in a mySQL table in the Magento system.
The advantage of generating the keys on the fly is that you aren't storing a big database of keys that someone could potentially grab; you're also less likely to run out if you have a lot of people purchase them.
The advantage of having a table full of keys that are generated elsewhere: you don't have the encyryption systems on the server that are used to generate the keys.
Either way, you'll need to use an extension to manage this functionality, as it doesn't exist in the default Magento system.
I hope this helps!