How to handle cancel order in ecommerce

Hello everyone, I integrated a new payment method: “Vnpay” into our e-commerce site.
I paid and entered the correct payment information, then I was enrolled to the course and the money was deducted from my account, which proves the payment integration was successful. However, during the payment process, I clicked cancel and didn’t know what to do next. Currently, after canceling the order, my money will not be deducted but the system will notify me of a successful order and will enroll me to that course. I checked all order status and it seems there is no “Cancel” status. For now, I can only return cancel_url but essentially it still creates order and the status still is “Complete”. Here is my handle code

and this is cancel_url redirect when user cancel order