Body: <p>Problem: I want to trigger an action (<a href="https://github.com/nystudio107/instantanalytics" rel="nofollow noreferrer">Instant Analytics</a> plugin) whenever a payment (Craft Commerce plugin) is successful (webhook). Payment provider is Mollie.</p>
  
  <p>So far I created a plugin that listens to the <code>onOrderComplete</code> event to send the analytics action. But it looks like the event <code>onOrderComplete</code> is not triggered.</p>
  
  <p>Here is the code</p>
  
  <pre><code>craft()-&gt;on('commerce_orders.onOrderComplete', function(Event $event) {
      craft()-&gt;instantAnalytics-&gt;analytics()-&gt;addCommerceCheckoutStep($event-&gt;params['order'], 4, 'Payed');
      craft()-&gt;instantAnalytics-&gt;analytics()-&gt;sendPageView();
  });
  </code></pre>
  
  <p>Question 1: Is this event a good one? Or is there an event that is thrown at the moment of a successful payment of an incoming webhook?</p>
  
  <p>Question 2: Why is the <code>onOrderComplete</code> event not thrown?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-12T17:28:49.123Z
Comments.Text: That event is fired with the order's `isComplete` bit is set and the order is fully paid. Is that the case with your orders?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-13T14:44:49.147Z
Comments.Text: Orders are becoming complete and payed. I will try to log something inside the event listener. Then I will know if the event is not triggered or the instant analytics is for some reason failing. Although the code of the instant analytics itself works, there might be an issue with the `$event->params['order']` parameter.. I will be back as soon as I have more info.
Comments.UserDisplayName: boldenamsterdam
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-16T08:21:42.017Z
Comments.Text: Well it according to the logs it looks like the event is actually triggered. The thing is that the page view is not sent and therefore it does not end up in analytics.. Maybe I will have to escalate this with the plugin developer..
Comments.UserDisplayName: boldenamsterdam
Tags: <plugin-development><plugin-craftcommerce><events><analytics><payment>
Title: commerce_orders onOrderComplete not triggered?
ThreadText: # commerce_orders onOrderComplete not triggered?
  
  (Asked by: username_0 on 2017-10-12)
  
  Problem: I want to trigger an action ([Instant Analytics](https://github.com/nystudio107/instantanalytics) plugin) whenever a payment (Craft Commerce plugin) is successful (webhook). Payment provider is Mollie.
  
  So far I created a plugin that listens to the `onOrderComplete` event to send the analytics action. But it looks like the event `onOrderComplete` is not triggered.
  
  Here is the code
  
  ```
  craft()->on('commerce_orders.onOrderComplete', function(Event $event) {
      craft()->instantAnalytics->analytics()->addCommerceCheckoutStep($event->params['order'], 4, 'Payed');
      craft()->instantAnalytics->analytics()->sendPageView();
  });
  
  ```
  
  Question 1: Is this event a good one? Or is there an event that is thrown at the moment of a successful payment of an incoming webhook?
  
  Question 2: Why is the `onOrderComplete` event not thrown?
  
  **Tags:** plugin-development, plugin-craftcommerce, events, analytics, payment
  
  > **Comments:**
  > **username_1**: That event is fired with the order's `isComplete` bit is set and the order is fully paid. Is that the case with your orders?  
  > **username_0**: Orders are becoming complete and payed. I will try to log something inside the event listener. Then I will know if the event is not triggered or the instant analytics is for some reason failing. Although the code of the instant analytics itself works, there might be an issue with the `$event->params['order']` parameter.. I will be back as soon as I have more info.  
  > **username_0**: Well it according to the logs it looks like the event is actually triggered. The thing is that the page view is not sent and therefore it does not end up in analytics.. Maybe I will have to escalate this with the plugin developer..  
  
  ---
  
  ## 0 answers
  
  