I get an error message saying in-app purchases are not allowed

Open the Settings app, navigate to General -> Restrictions and make sure the "In-App Purchases" setting is ON.