Automatic Digital Delivery

Does anybody know how i can setup digital delivery for my site.

so for example i am selling Xbox live 1 month , when one customer buys it it needs to send them an email with a 1 month xbox live code , that code then needs to be deactivated from sending to other customers who buy the same product and they receive a different code. there are many websites that use this but i cant seem to find anything that lets me do this.