onAfterOrderUpdate not triggered on paypal confirm

  • Posts: 4
  • Thank you received: 0
8 years 8 months ago #210522

-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.2.7
-- PHP version -- : 5.3.2

Hello,

We create a plugin which works "perfectly" :) . If the order is change to confirmed state, a email with a pdf (invoice) is created and send to the customer. There is only one issue:

If the user pays via paypal the plugin is not invoked. The order is confirmed, but it seems not to trigger the plugin. If I change the state back to open (in the backend) and back to confirmed, the trigger is invoked.

Thanks for help,
Dirk

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
8 years 8 months ago #210533

Hi,

The paypal plugin works like a lot of other payment plugin ; it receives a notification (IPN) to confirm the order.
At this moment the plugin will modify the order and it will trigger the trigger "onAfterOrderUpdate".
Because it's not the user who confirmed his order, you can't see it in your browser ; the confirmation is made during a server-to-server call.
But in any case, the trigger is called !

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 4
  • Thank you received: 0
8 years 8 months ago #210926

Hi Jerome,

but why is the emai not created. My plugin creates a pdf invoice and sends it via email:

Some extract:

class plgHikashopAsado_invoice extends JPlugin {
....
	function onAfterOrderUpdate(&$order, &$send_email) {
		if ($order->order_status == 'confirmed') {
			$mailer = JFactory::getMailer ();
			
			// set sender & recipient
			$mailer->setSender ( $order->mail->from_email );
....						
			// sending the email
			$send = $mailer->Send ();
			if ($send) {
				JFactory::getApplication ()->enqueueMessage ( 'A mail was send.' );
			} else {
				JFactory::getApplication ()->enqueueMessage ( 'The billing email could not be send.', 'error' );
				return false;
			}
		}
	}

As I mention, it works completly fine if I switch the order state in the backend.

Thanks,
Dirk

Last edit: 8 years 8 months ago by dirkey.

Please Log in or Create an account to join the conversation.

  • Posts: 81484
  • Thank you received: 13062
  • MODERATOR
8 years 8 months ago #210929

Hi,

I don't see any reason why it wouldn't work if it works on the backend. We have many plugins which use that method in order to do things when an order is confirmed.
We actually already have a PDF invoice plugin which works like that:
hikashop.com/component/hikashop/product/cid-18.html
You must have an issue somewhere in the code of the plugin with something which can only work in the backend, not the frontend.
For example, if you're using the loadFullOrder function call in order to load the details of the order, this will always work in the backend, but on the frontend, as the user loading the order is not the customer but the PayPal notification server, you need to add additional parameters when calling it in order to disable the check on the current user.

Please Log in or Create an account to join the conversation.

Time to create page: 0.065 seconds
Powered by Kunena Forum