Jump to content

Prevent order status update


pisod

Recommended Posts

Hi

 

Im developing a payment module and I have trouble to change or prevent a status update when using the hooks actionOrderStatusUpdate and actionOrderStatusPostUpdate. The scenario that I have is that an order can have been authorized by the bank but now needs to be captured.

 

When the merchant/admin changes the order status from Authorized (my custom status) to Payment Accepted I catch that change in the above hooks and make server calls to my companies server (Payment provider) who then contacts the banks. If the payment/order gets captured everything is fine. But what happens if something goes wrong and the status Payment Accepted is no longer the correct status. How do I prevent the status update?

 

Im using Prestashop 1.6 and the module should also support 1.5.

 

/Pierre

Link to comment
Share on other sites

you could use actionPaymentConfirmation hook, since that is only triggered when changing to Payment Accepted, where the other hooks are executed for all order states.

 

however you are not able to stop the process using these 3 hooks.  The hooks are executed, but the process continues regardless of your processing.

 

If using actionPaymentConfirmation or actionOrderStatusUpdate which fire before the status changes, then you could try to redirect the user to a different page (and exit/die), which may prevent the order status from changing.

Link to comment
Share on other sites

Thanks bellini13 for your answer. I tried a different approach.

 

I solved it by hooking into the adminOrder-hook and added a html-form where the merchant/admin will be displayed with the option to capture the payment if it has been authorized (but not captured). And after merchant/admin has pressed my custom-added button I try to capture the payment and if success I just set the status to PS_OS_PAYMENT or if fail to error. To display the new status I just redirect like this: Tools::redirect($_SERVER['HTTP_REFERER']);

 

Since this hook is not part of the update-status-process everthing works perfect.

 

Hopes this helps somebody else.

Link to comment
Share on other sites

yup, that is how I do it in my payment modules.  The only thing to watch out for is if the user just changes the status to payment accepted without capturing the transaction.

Yes you are right, thanks for that. How do you warn/inform the merchant/admin if that happens?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...