Jump to content

Execute Action after New Order Created Not Working for Paypal Payment Gateway Only


Recommended Posts

I have created a custom module which executes an action after new order has been created. The order will be sent to delivery company via API.

Currently, I am having an issue whereby the code executes when I am using payment with STRIPE while for Paypal, it is not executing the action at all.

The hook I am currently using is called hookActionValidateOrder. Since this hook executes the action when an order is created, I do not understand why it is currently not working for Paypal. It should execute or not execute based on payment gateway, right?

Alternatively, is there any other hooks I can use apart from hookActionValidateOrder?

Thank you for your insights and guidance.

Link to comment
Share on other sites

  • 3 weeks later...

Hi belleni13, 

I have added a status called "Payment Validated" that is reflected on the order after it is created. It is the same for STRIPE or PayPal payment mode that is also being used.

I have enabled DEBUG_MODE and checked in DB on the log. It has indeed logged the following:

"PaymentModule::validateOrder - Hook validateOrder is about to be called"

Is there anywhere else I should be looking?

Thank you.

Link to comment
Share on other sites

how do you know the hook is NOT being called?  perhaps you have not properly registered the hook in your module.  what kind of debugging have you done to validate that the module registered the hook properly?  did you add any kind of debug statement to your module to detect if the hook is being called or not?

Link to comment
Share on other sites

clues?  no you have not provided anything...  you need to continue to debug and as I mentioned earlier...

how do you know the hook is NOT being called?  perhaps you have not properly registered the hook in your module.  what kind of debugging have you done to validate that the module registered the hook properly?  did you add any kind of debug statement to your module to detect if the hook is being called or not?

Link to comment
Share on other sites

Hi bellini13, 

I have checked in database - log that the hook is being called. I am using hookActionValidateOrder, so when an order is using a specific carrier, it will execute a set of codes/actions.

The module I have implemented is working only when I use STRIPE payment mode. It will not run nor execute the codes if I am using PayPal.

My module is hooked actionValidateOrder and I have checked from back-office - Modules > Positions.

Thank you.

Link to comment
Share on other sites

21 hours ago, Enthu86 said:

I have checked in database - log that the hook is being called

what does this mean?  You cannot look in the database to confirm that YOUR CUSTOM MODULE hook function was called...

You need to add some code in your CUSTOM MODULE hook function, make it the first thing it does, and verify that your CUSTOM MODULES hook function is actually being called or not.

Link to comment
Share on other sites

Hi bellini13, 

I am using hookActionValidateOrder($params) in my custom module. And that when the cart calls this, my code will execute, right? That was why I checked if the hook is being called in database.

It is only working if I use STRIPE so I was wondering or how can I debug on this for PayPal?

Thank you.

Link to comment
Share on other sites

the database does not record hooks that are actually called during runtime.  it only captures hooks that SHOULD be called, not ones that are ACTUALLY called.

perhaps the paypal module you are using is not creating an order? and so the hook is no being called.

perhaps your module is not coded properly

perhaps you have some customization on your store that is preventing this from working properly

IDK, there could be a million reasons why this is not working for you.  you need to roll up your sleeves and start digging in the code and really see what is going on. 

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...