Here’s how you can prevent in-app purchases on an iPhone in 2020. This guide is for iPhones with the current iOS version 13 as of March 2020, but it should work with earlier versions, too.
Go to Settings / Screen Time / Content & Privacy Restrictions.
Tap the Content & Privacy Restrictions button to enable it.
Then, on the same screen, continue to iTunes & App Store Purchases / In-App Purchases.
Select the Don’t allow option.