This is actually a permissions issue related to being allowed to make purchases.
If you belong to a Family Sharing group or have Parental Control restrictions enabled, please verify that the “Ask to Buy” feature is not enabled for your account.
You can check this by going into your device's Settings > Screen Time > Content & Privacy Restrictions > iTunes & App Store Purchases.
This is where you can find how your device or Family Sharing account is limited regarding purchases. You'll need to edit these restrictions (or have your parent or account owner do it) in order to be able to make in-app purchases.
Here’s more about this feature.