This document explains how to add a payment method to your Apple ID on a Mac, Apple mobile devices, PC, or online. Click here --> Add a payment method to your Apple ID - Apple Support
On an iPhone:
Open the Settings app.
Tap your name.
Tap Media & Purchases, then tap View Account. You might be asked to sign in with your Apple ID.
Tap Manage Payments.
To find out how to remove a payment method, and what to do if you can't remove your last payment method or use no payment method with your Apple ID, read this article --> Remove a payment method from your Apple ID - Apple Support
Ongoing subscriptions and Family Sharing organizers must always have a payment method present. To edit the cards used for those you may need to first add the new card and make it the primary payment method before removing the old card (see: If you need to change or update your Apple ID payment method - Apple Support ).