Switch from free to paid app

How to make a free app with limitations to a paid app without limitations on google play? Do I have to make two apps? Or do I just make an application and via code after making the purchase it changes to complete? How to proceed? From what I read on google play each application has its ID, if you put a free and a paid version, they have nothing in common.

I need to make a sale within the app to release all functions, I used a branch with a boolean, and a string with the value “paid”, if it has this value, it releases the boolean, but how do I communicate with the google play store?