Correction At the time of paying if stock of the items = 0

At the time of paying if the stock of the article passes in 0
redirect to cart
redirectToRoute is deprecated, use generateRedirectFromRoute instead and be careful, this method return a reponse.

Maybe you can add a get parameter to this route and catch it in the cart view for displaying an error message ?