Jump to content

Add an action when payment is accepted


Pierre.CIHOLAS

Recommended Posts

Hello,

 

First, thank you for your forums and the documentation section of your website, I learnt a lot about Prestashop in there.

 

I set up Prestashop on my server and I use prestashop to sell tickets (with a unique number on each ticket, saved in a mysql DB with Prestashop tables).

I just want to add some actions when orders placed on Prestashop are paid (when the payment is accepted, regardless of the payment method of course).

 

I was about to modify the PaymentModule class (classes/PaymentModule.php) and add my actions in there. Would it works ?

It will be problematic when I will update Prestashop to the lastest version (the file will probably be erased).

 

What is the best way to add actions when the payment of an order is accepted ?

 

Thank you in advance for your answers.

Link to comment
Share on other sites

  1. not always, have to check the valid status of the order available in params
  2. as per my understanding of prestashop, major hooks are only executed for front office, only few are for back office admin page, although code can be tweaked to do so. And this is not executed in backoffice state change of orders.

Link to comment
Share on other sites

  • 1 year later...
  • 8 months later...

I want to do the same thing. I was hoping the hook "actionPaymentConfirmation" would do this for me. Running through with XDebug but the hook is never called when I set the order-status to "payment accepted" nor "payment remotly accepted". Rather new to Prestashop. Am I missing something?

    public function install() {
        
        if (!parent::install() || !$this->registerHook("actionPaymentConfirmation")) {
            return false;
        }
        return true;
    }

    public function actionPaymentConfirmation($params) {
        ...// some code here, but function is not being invoked
    }
Edited by Mirm (see edit history)
Link to comment
Share on other sites

you could also try "actionOrderStatusUpdate" hook.  Both of these hooks are called when the order status is changed.  "actionOrderStatusUpdate" is called for any status change, "actionPaymentConfirmation" is only called for "PS_OS_PAYMENT" and "PS_OS_WS_PAYMENT"

  • Like 1
  • Thanks 1
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...