I am new to Stripe and I can't figure out how to handle the such situation:
Instead of this, I want to revert the subscription to the previous one, because there are still N paid days of the previous subscription.
I'm going to restate your issue here to make sure we are on the same page and provide context for my answer
You can configure how a modified Subscription responds to a payment failure by changing the payment_behavior
parameter when making the the Update API request. In your case you want to provide pending_if_incomplete
.
This will only change the Subscription if payment succeeds. You can read the overview here and get details about parameter restrictions and the lifecycle of pending updates here