For contracts, you have to specify the maximum number of keys (local and/or global) that you will ever need, at contract creation time. Then the contract creator has to cover the MBR for global state, and each account opting-in has to cover the MBR for local-state, if any.
Only the upcoming box storage is really ‘pay as you go’