I'm developing a Prestashop module to achieve this.
When an order with a specific product is placed I need to contact an external API to perform some write operations. To be more specific, some product will be automiatically ordered on a third party platform. It's not dropshipping, I'm sending the order to the producer of the goods.
The problem is, if the API call goes bad i must stop the order from being placed and notify the client that something has gone wrong, keeping the cart intact if possibile.
Everything else is working: i can detect the products, send the info to the third party api and read the response. Except I'm using a Module with this code:
$this->registerHook('actionValidateOrder');
It is my understanding this hook is called after an order is placed, so I can't block it if the API call goes wrong.
What is the right way to approach this scenario?
I tried to use actionOrderStatusPostUpdate but I don't think i can have prior knowledge on the order status (payment methods can vary).
Any idea? Seems like a basic task to accomplish but I'm stuck.
Using Prestashop 1.7.8