Thank you for using Apple Support Communities.
I understand from your post that when downloading an app from the App Store it asks for your security code but when you enter it says it is invalid. In a situation like this I recommend verifying that all your billing information is entered exactly as it is on your billing statement. The following article has information on how to change or remove your billing information:
Change or remove your Apple ID payment information - Apple Support
Best Regards.