You would probably want eCart and Data Bridge to pull this off.
Then you could use the image upload and download features to upload the codes and allow purchasers to download them, and then delete them.
You might also consider Powerstore, which is a pre-built solution that includes digital goods and could save you a lot of time and heartache if used as a starting point.