Hi,
If you don't enter any "return URL" in your payment method, you'll indeed go to the after_end view file for most payment methods.
So if you entered a return URL the after_end view file won't be called. That could be why you don't get your redirect to work.
You can always have more complex code with conditions, but it will be quite complex since you can have several products in the same order, and several categories per product, and that the data of the order/products/categories is not loaded (so you first need to load all that with MySQL queries).