Plugin onAfterOrderConfirm triggers not being called.

  • Posts: 144
  • Thank you received: 4
  • Hikashop Business
9 years 5 months ago #205469

-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.4.1
-- PHP version -- : 5.3.28

We're working on a checkout process using the basic PayPal payment plugin in combination with a Hikashop plugin of our own creation which creates a reservation db record when an order containing certain items is created - and activating that reservation when the payment is confirmed by PayPal.

The custom plugin uses "onAfterUserCreate()" to assign the new user to a specific group. It also uses "onAfterOrderCreate()" to build the reservation db entry. These work fine and correctly.

The problem is that the plugin never receives either the "onAfterOrderUpdate()" or the "onAfterOrderConfirm()" triggers, which we need in order to finish the process.

The PayPal plugin IS working properly (although "debug" mode does not automatically write output to the Payment Log file - I manually inserted hika's log-writing triggers inside it to follow its progress from beginning to end to check it, and that does work. ) It process the Notification from PayPal and it properly changes the Hikashop order's status, as well as emailing the change notification to us.

But our own plugin never receives that final trigger which will activate the reservation. (The methods currently contain various commands which would make it very visible if they were processed. Users are transmitted normally to Hika's "Thank You" output without them being triggering.)

How can we tell if these triggers are being sent? Could they be like "onPaymentNotification()", which is sent only to the payment plugin in use? Could I locate where the triggers are being activated/sent? Do you have suggestions for some other way I can troubleshoot this?

Thank you for your help.

Attachments:

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

  • Posts: 144
  • Thank you received: 4
  • Hikashop Business
9 years 5 months ago #205470

BTW, Paypal is being automatically redirected after purchase to the url

index.php?option=com_hikashop&ctrl=checkout&task=notify&notif_payment=paypal

and the data it receives appears to match Paypal's specs. The plugin's notification routines seem to be behaving normally. I really don't think PayPal itself is involved. This problem appears to happen after the PayPal plugin does everything it needs to do.

Last edit: 9 years 5 months ago by icomex. Reason: URL was butchered by editor

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

  • Posts: 26159
  • Thank you received: 4028
  • MODERATOR
9 years 5 months ago #205475

Hi,

Only the selected payment plugin will be triggered for the event "onAfterOrderConfirm".
You can be triggered with an another kind of plugin (or if your payment plugin is not used for the order).

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: 144
  • Thank you received: 4
  • Hikashop Business
9 years 5 months ago #205554

Thank you, Jerome.

So the PayPal confirmation triggers BOTH onAfterOrderConfirm AND onAfterOrderUpdate ONLY to the payment plugin that is in use? There are several forum threads (including #140727 ) which indicate that onAfterOrderUpdate should be called after the Payment plugin has modified the Hikashop order ...

It would appear that the only way to trigger an alteration to the newly created order after payment confirmation is to override or replace the Payment plugin, which would mean manually checking and updating this new plugin every time HikaShop is updated. Is that correct?

Since the "Order" in the onAfterOrderXXX triggers refers to the Hikashop order, not to the payment request, why should these triggers be sent solely to the Payment Plugin, especially while the Payment plugin is already receiving the onPaymentConfirm trigger from the Payment API? It would seem that onAfterOrderXXX triggers should be sent to all Hika Plugins just as onBeforeOrderCreate are.

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

  • Posts: 82910
  • Thank you received: 13379
  • MODERATOR
9 years 5 months ago #205567

Hi,

The trigger onAfterOrderUpdate is called for all the plugins of the groups system, hikashop, hikashoppayment, hikashopshipping and system after an order is modified.
It's only the trigger onAfterOrderConfirm which is called only for the plugin selected for the order as it's a specific trigger which purpose is to provide the HTML to add to the page at the end of the checkout (when the order creation is confirmed by the user) for the redirection to the payment gateway.
It's the same with the onPaymentConfiguration and onPaymentConfigurationSave triggers which are called when the payment method setting page is displayed/saved and thus where only the plugin relative to the payment method being displayed/saved is called.

So no, you can of course have your own plugins triggered when an order is confirmed, or modified in another way thanks to the onAfterOrderUpdate trigger. We actually already use that a lot even by default in HikaShop. For example, the history plugin of HikaShop is triggered when an order is modified and it then logs a new history entry for the order at that point.

I guess that your issue is that you though that the onAfterOrderConfirm trigger was to get triggered when an order is confirmed, which is not the case, as explained in the developer documentation:
www.hikashop.com/support/support/documen...r-documentation.html

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

  • Posts: 144
  • Thank you received: 4
  • Hikashop Business
9 years 5 months ago #205666

I appreciate the explanation, which is precisely what I expected and hoped for, but my issue (if you examine the code included in the first post) is that I have a method set up for onAfterOrderUpdate that it is NOT being activated. I don't understand why.

Here is the first method, expanded ( the old-style _construct method ).

function plgHikashopBrainstyles( &$subject, $config )
		{
			parent::__construct( $subject, $config );
			$this->user = JFactory::getUser();
			$this->user->demographics = JUserHelper::getProfile( $this->user->id );

			if( !isset( $this->params ) )
			{
				$plugin = JPluginHelper::getPlugin( 'hikashop', 'brainstyles' );
				$this->params = new JRegistry( $plugin->params );
			}
		}

Is there something incorrect here or something else I need to do to receive that post-payment trigger? Remember, I DO receive the onAfterOrderCreate trigger call correctly. I just don't receive the calls which occur after the Payment.

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

  • Posts: 82910
  • Thank you received: 13379
  • MODERATOR
9 years 5 months ago #205699

Hi,

If onAfterOrderCreate is triggered in your plugin, then onAfterOrderUpdate will be triggered too.
There is no way it is not.

Your issue is probably in your assumptions.
I see that what you do in the onAfterOrderUpdate code is only displaying text.
And you're saying that you're testing with the PayPal plugin confirmation of orders.
This process is triggered directly by a PayPal server and thus, what is displayed by the website in that process is sent back to the PayPal server which contacted the website for the payment notification.
So it's normal that you don't see anything as the customer.
If you don't add the die at the end of the function, during payment notifications, HikaShop will automatically log what you output in your plugin to the payment log file that you can see in the Files section of the HikaShop configuration.
With the die, the text is sent back directly to PayPal by your server so there is no point displaying any text as PayPal doesn't care and you won't see it anywhere.

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

  • Posts: 144
  • Thank you received: 4
  • Hikashop Business
9 years 5 months ago #205788

THAT's the missing piece!

I had assumed that the onAfterOrderUpdate trigger was sent when PayPal redirects back to the original website, instead of paypal sending both a notification transaction AND a redirect request separately.

A minor confusion: when the onAfterOrderUpdate method receives the Order object as input, its new status is marked as "cancelled" instead of 'confirmed'. At the same time, there is a history object included which logs the 'payment', which is the change I will look for to verify that the payment has been received. Is the 'cancelled' status normal or is it an artifact of the timing of PayPal's transaction?

Thank you very much for your help. I would never have figured this out without your assistance.

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

  • Posts: 82910
  • Thank you received: 13379
  • MODERATOR
9 years 5 months ago #205810

Hi,

In your PayPal payment method, you can configure the status you want when the payment is successful, invalid, etc.

By default, "cancelled" is only set when the payment notification received is invalid.
This will happen in two cases:
- the amount paid and the order amount are different
- the email of the receiver is different than the merchant email set in the settings of the PayPal payment method

If you turn on the "debug" setting of your PayPal payment method, you'll get data in the logs giving you the necessary information on the matter. You should also receive a payment notification email with some information on the issue in such case.

The following user(s) said Thank You: icomex

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

  • Posts: 144
  • Thank you received: 4
  • Hikashop Business
9 years 5 months ago #206274

Your suggestions appear to have resolved the 'cancelled' issue, and your earlier message did resolve the original issue.

Thank you for your time and effort!

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

Time to create page: 0.078 seconds
Powered by Kunena Forum