Subscription upgrades and downgrades

I’m using the Stripe for payments and subscriptions.

There are multiple tiers for the subscriptions - Basic, Pro and Business.

If someone is on Basic and they upgrade to Pro, how do I set it such that the Basic plan will automatically get canceled.
And vice versa if someone chooses to downgrade.

Any tips?