Users redeem codes from inside the App Store app on their phone.
You can generate codes to give you app away for free, or to grant a free in-app purchase, but that is all. There's no callbacks from the app store to your app to intercept.
Possibly you could do what you want with QR codes and launch URLs, or by doing camera+OCR stuff yourself inside your app.