"Invalid security code" error means your card issuer isn't authorizing iTunes to use the card. The error is actually a general error and doesn't necessarily mean you're typing in the wrong CVV. It can be caused by a security hold on your card that may only be affecting iTunes purchases, insufficient funds, actually typing in the wrong CVV, or other issues but only your bank can tell you why this is happening. When you get a prompt saying there is a billing issue with a previous purchase, it means that your bank or credit card company didn't authorize iTunes to receive payment for something purchased with your account. When you try to update payment info, iTunes is asking permission to receive payment from your card issuer, and they're not authorizing that.
Call your bank to resolve the issue with the card or use an iTunes Gift Card to take care of an unpaid balance.