How to cancel the last order and restore the last quote on an unsuccessfull payment?

Details:

  1. How to cancel the last order on an unsuccessfull payment?