[Skip to main content](#vessel-content)

#   onAfterOrderConfirm not triggering

##

- **[eleventy](/forum/user/25916-eleventy "View eleventy's Profile")**
- [![eleventy's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/25916-eleventy "View eleventy's Profile") Topic Author
- [ Offline](/forum/user/25916-eleventy)

Less More

- Posts: 7
- Thank you received: 0
-
-

13 years 2 months ago -  13 years 2 months ago [\#117346](#117346) by [eleventy](/forum/user/25916-eleventy "View eleventy's Profile")  *[onAfterOrderConfirm not triggering](/forum/31-development/860707-onafterorderconfirm-not-triggering#117346 "I'm getting there :)  Below is the code I'm working on to integrate Hikashop with Kashflow (accounts).  I want to trigger my script onAfterOrderConfirm, but it doesn't trigger. I get the order confirmation sent to the customer, but no invoice in Kashflow. If I change to it works, but this is not what I want. I want to be sure payment has been received.  Have I made a mistake with the trigger code change?  Many thanks Eleventy")* was created by *[eleventy](/forum/user/25916-eleventy "View eleventy's Profile")*

I'm getting there ![:)](/media/kunena/emoticons/8.png ":)")

Below is the code I'm working on to integrate Hikashop with Kashflow (accounts).
Code:

&lt;?php defined('_JEXEC') or die('Restricted access'); ?&gt;&lt;?php if(!@include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')){ return false; } class plgHikashopkf_insert extends JPlugin { function plgHikashopKashflow(&amp;$subject, $config){ parent::__construct($subject, $config); if(!isset($this-&gt;params)){ $plugin =&amp; JPluginHelper::getPlugin('hikashop', 'kf_insert'); jimport('joomla.html.parameter'); $this-&gt;params = new JParameter( $plugin-&gt;params ); } } function onAfterOrderConfirm(&amp;$order, &amp;$methods, $method_id) { if(!empty($order-&gt;order_id)){ $orderClass = hikashop_get('class.order'); $full_order = $orderClass-&gt;loadFullOrder($order-&gt;order_id, true, false); require_once("**********.inc.php"); require_once("******.inc.php"); $username = "******"; $password = "*******"; //create variables $order_user_id = $full_order-&gt;order_user_id; mysql_connect("localhost", "*************", "**************") or die(mysql_error()); mysql_select_db("****************") or die(mysql_error()); $email = mysql_result(mysql_query("SELECT user_email FROM nl7xh_hikashop_user WHERE user_id = '".$order_user_id."';"), 0); foreach($full_order-&gt;products as $product){ $cart = $product-&gt;order_product_name; $subtotal = $product-&gt;order_product_price; } $inv_name = $full_order-&gt;shipping_address-&gt;address_firstname . " " . $full_order-&gt;shipping_address-&gt;address_lastname; //ok $inv_addr1 = $full_order-&gt;shipping_address-&gt;address_street; $inv_addr2 = $full_order-&gt;shipping_address-&gt;address_city; $inv_state = $full_order-&gt;shipping_address-&gt;address_state; $inv_zip = $full_order-&gt;shipping_address-&gt;address_post_code; $inv_country = $full_order-&gt;shipping_address-&gt;address_country; $description = $cart; $qty = '1'; $tax_rate = 20; $tel = $full_order-&gt;shipping_address-&gt;address_telephone; $shipping = $full_order-&gt;shipping-&gt;shipping_price; // Kashflow will check if it's available and increment it if already used. $invoice_number = 1; // Uses format yyyy-mm-dd. $invoice_date = date("Y-m-d"); // current date $due_date = strtotime(date("Y-m-d", strtotime($invoice_date)) . " +30 days"); //net 30 // below is the nominal id code for Sale of Goods. $nominal_id = 1236497; $kashflow_customer_id; //First we will try to get this id from an email if not we will create it //**************** Test For User ***************// $kashflow = new Kashflow($username,$password); $results = $kashflow-&gt;getCustomerByEmail($email); //Checks to see if the email exists and creates a new account if not if($results-&gt;StatusDetail == 'There is no customer with that email address'){ $name = $inv_name; $address = $inv_addr1; $town = $inv_addr2; $state = $inv_state; $postcode = $inv_zip; $country = $inv_country; $tel = $tel; $newCustomerResults = $kashflow-&gt;insertCustomer($name,$address,$town,$state,$postcode,$country,$email,$telS); $kashflow_customer_id = $newCustomerResults-&gt;InsertCustomerResult; }else{ $kashflow_customer_id = $results-&gt;GetCustomerByEmailResult-&gt;CustomerID; } $unit_net = $subtotal + $shipping; //This should be true unless you use bad data to create account. if($kashflow_customer_id){ // Connect to Kashflow. $kashflow = new Kashflow($username,$password); // Initialise the invoice. $invoice = new KashflowInvoice($kashflow_customer_id,$invoice_number,$invoice_date,$due_date); // Add a line to the invoice: 1 unit, with a unit price of £10 @ 20% VAT. $invoice-&gt;addLine($qty,$unit_net,$unit_tax,$tax_rate,$nominal_id,$description); // Now insert the invoice on Kashflow. $response = $kashflow-&gt;insertInvoice($invoice); // Done - here's the response! echo "&lt;pre&gt;"; print_r($response); echo "&lt;/pre&gt;"; }else{ echo "&lt;p&gt;CustomerID is not valid: ".$kashflow_customer_id."&lt;/p&gt;"; } } return true; } } ?&gt;

I want to trigger my script onAfterOrderConfirm, but it doesn't trigger. I get the order confirmation sent to the customer, but no invoice in Kashflow. If I change Code:

function onAfterOrderConfirm(&amp;$order, &amp;$methods, $method_id) {

to Code:

function onAfterOrderCreate(&amp;$order,&amp;$send_email){

it works, but this is not what I want. I want to be sure payment has been received.

Have I made a mistake with the trigger code change?

Many thanks
Eleventy

Last edit: 13 years 2 months ago by [eleventy](/forum/user/25916-eleventy "View eleventy's Profile"). Reason: redaction

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2MDcwNy1vbmFmdGVyb3JkZXJjb25maXJtLW5vdC10cmlnZ2VyaW5nP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86315
- Thank you received: 14276
-
-

13 years 2 months ago [\#117350](#117350) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[onAfterOrderConfirm not triggering](/forum/31-development/860707-onafterorderconfirm-not-triggering#117350 "I'm getting there :)  Below is the code I'm working on to integrate Hikashop with Kashflow (accounts).  I want to trigger my script onAfterOrderConfirm, but it doesn't trigger. I get the order confirmation sent to the customer, but no invoice in Kashflow. If I change to it works, but this is not what I want. I want to be sure payment has been received.  Have I made a mistake with the trigger code change?  Many thanks Eleventy")*

This function is triggered at the end of the checkout process after the order has been created so that the payment plugin can redirect the user to the payment platform for the payment.
Please make sure that you're extending from the hikashopPaymentPlugin class or you'll be missing a lot of code from your plugin and it won't work properly during the checkout if you're using HikaShop 2.2 or above.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2MDcwNy1vbmFmdGVyb3JkZXJjb25maXJtLW5vdC10cmlnZ2VyaW5nP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[eleventy](/forum/user/25916-eleventy "View eleventy's Profile")**
- [![eleventy's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/25916-eleventy "View eleventy's Profile") Topic Author
- [ Offline](/forum/user/25916-eleventy)

Less More

- Posts: 7
- Thank you received: 0
-
-

13 years 2 months ago -  13 years 2 months ago [\#117356](#117356) by [eleventy](/forum/user/25916-eleventy "View eleventy's Profile")  Replied by *[eleventy](/forum/user/25916-eleventy "View eleventy's Profile")* on topic *[onAfterOrderConfirm not triggering](/forum/31-development/860707-onafterorderconfirm-not-triggering#117356 "I'm getting there :)  Below is the code I'm working on to integrate Hikashop with Kashflow (accounts).  I want to trigger my script onAfterOrderConfirm, but it doesn't trigger. I get the order confirmation sent to the customer, but no invoice in Kashflow. If I change to it works, but this is not what I want. I want to be sure payment has been received.  Have I made a mistake with the trigger code change?  Many thanks Eleventy")*

Thanks Nicolas for your continued support ![:)](/media/kunena/emoticons/8.png ":)")

What would be the best trigger/function to use? I just need my Kashflow script to execute when the customer has paid.

Last edit: 13 years 2 months ago by [eleventy](/forum/user/25916-eleventy "View eleventy's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2MDcwNy1vbmFmdGVyb3JkZXJjb25maXJtLW5vdC10cmlnZ2VyaW5nP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[eleventy](/forum/user/25916-eleventy "View eleventy's Profile")**
- [![eleventy's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/25916-eleventy "View eleventy's Profile") Topic Author
- [ Offline](/forum/user/25916-eleventy)

Less More

- Posts: 7
- Thank you received: 0
-
-

13 years 2 months ago [\#117364](#117364) by [eleventy](/forum/user/25916-eleventy "View eleventy's Profile")  Replied by *[eleventy](/forum/user/25916-eleventy "View eleventy's Profile")* on topic *[onAfterOrderConfirm not triggering](/forum/31-development/860707-onafterorderconfirm-not-triggering#117364 "I'm getting there :)  Below is the code I'm working on to integrate Hikashop with Kashflow (accounts).  I want to trigger my script onAfterOrderConfirm, but it doesn't trigger. I get the order confirmation sent to the customer, but no invoice in Kashflow. If I change to it works, but this is not what I want. I want to be sure payment has been received.  Have I made a mistake with the trigger code change?  Many thanks Eleventy")*

I think onAfterOrderUpdate will work, if I run my script only when the order is confirmed not created.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2MDcwNy1vbmFmdGVyb3JkZXJjb25maXJtLW5vdC10cmlnZ2VyaW5nP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86315
- Thank you received: 14276
-
-

13 years 2 months ago [\#117375](#117375) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[onAfterOrderConfirm not triggering](/forum/31-development/860707-onafterorderconfirm-not-triggering#117375 "I'm getting there :)  Below is the code I'm working on to integrate Hikashop with Kashflow (accounts).  I want to trigger my script onAfterOrderConfirm, but it doesn't trigger. I get the order confirmation sent to the customer, but no invoice in Kashflow. If I change to it works, but this is not what I want. I want to be sure payment has been received.  Have I made a mistake with the trigger code change?  Many thanks Eleventy")*

Then my question is : how and when are your orders confirmed ? What is confirming them ?
Normally, it's the payment plugin itself which confirms the orders. So you should actually do that in the plugin. So asking me where to put your script when the order is confirmed is strange since you should be the one confirming it and thus you should already know where to put your script.

Here is how most payment plugins work:
1. the user finish the checkout
2. the order is created
3. the onAfterOrderConfirm function is called
4. in that function the plugin displays the redirection form to the payment platform and also specifies the "notification URL".
5. the user is redirected to the payment platform and pays the order
6. the payment platform notifies the "notification URL" of the payment being successful
7. at that point the onPaymentNotification function of the plugin is called
8. the plugin checks that the notification is valid
9. the plugin finally confirms the order

So basically, in most payment plugins, the two main functions are onAfterOrderConfirm, in order to redirect the user to the payment gateway, and onPaymentNotification, in order to confirm the order.

The following user(s) said Thank You: [lionel75](/forum/user/11856-lionel75 "View lionel75's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2MDcwNy1vbmFmdGVyb3JkZXJjb25maXJtLW5vdC10cmlnZ2VyaW5nP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mitchie](/forum/user/11906-mitchie "View mitchie's Profile")**
- [![mitchie's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/11906-mitchie "View mitchie's Profile")
- [ Offline](/forum/user/11906-mitchie)

Less More

- Posts: 60
- Thank you received: 1
-
-

12 years 9 months ago [\#140719](#140719) by [mitchie](/forum/user/11906-mitchie "View mitchie's Profile")  Replied by *[mitchie](/forum/user/11906-mitchie "View mitchie's Profile")* on topic *[onAfterOrderConfirm not triggering](/forum/31-development/860707-onafterorderconfirm-not-triggering#140719 "I'm getting there :)  Below is the code I'm working on to integrate Hikashop with Kashflow (accounts).  I want to trigger my script onAfterOrderConfirm, but it doesn't trigger. I get the order confirmation sent to the customer, but no invoice in Kashflow. If I change to it works, but this is not what I want. I want to be sure payment has been received.  Have I made a mistake with the trigger code change?  Many thanks Eleventy")*

Hi Nicolas,
I need to trigger my own plugin after payment (paypal) confirm. From your workflow I understand I need step
10. onPaymentConfirm
which unfortunately doesn't exists (if I'm not wrong).
Isn't it?
If so, can I asky you why don't you add that function?

Thanks in advance

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2MDcwNy1vbmFmdGVyb3JkZXJjb25maXJtLW5vdC10cmlnZ2VyaW5nP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86315
- Thank you received: 14276
-
-

12 years 9 months ago [\#140727](#140727) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[onAfterOrderConfirm not triggering](/forum/31-development/860707-onafterorderconfirm-not-triggering#140727 "I'm getting there :)  Below is the code I'm working on to integrate Hikashop with Kashflow (accounts).  I want to trigger my script onAfterOrderConfirm, but it doesn't trigger. I get the order confirmation sent to the customer, but no invoice in Kashflow. If I change to it works, but this is not what I want. I want to be sure payment has been received.  Have I made a mistake with the trigger code change?  Many thanks Eleventy")*

Hi,

There is already such function. It is called onAfterOrderUpdate which is triggered each time the order is changed.
So simply implement that trigger and in it, you verify that the $order-&gt;order_status is confirmed and the the $order-&gt;old-&gt;order_status is created and you'll know that the order has just been confirmed.
You can read more on that trigger in our developer documentation.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2MDcwNy1vbmFmdGVyb3JkZXJjb25maXJtLW5vdC10cmlnZ2VyaW5nP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[mitchie](/forum/user/11906-mitchie "View mitchie's Profile")**
- [![mitchie's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/11906-mitchie "View mitchie's Profile")
- [ Offline](/forum/user/11906-mitchie)

Less More

- Posts: 60
- Thank you received: 1
-
-

12 years 9 months ago [\#140729](#140729) by [mitchie](/forum/user/11906-mitchie "View mitchie's Profile")  Replied by *[mitchie](/forum/user/11906-mitchie "View mitchie's Profile")* on topic *[onAfterOrderConfirm not triggering](/forum/31-development/860707-onafterorderconfirm-not-triggering#140729 "I'm getting there :)  Below is the code I'm working on to integrate Hikashop with Kashflow (accounts).  I want to trigger my script onAfterOrderConfirm, but it doesn't trigger. I get the order confirmation sent to the customer, but no invoice in Kashflow. If I change to it works, but this is not what I want. I want to be sure payment has been received.  Have I made a mistake with the trigger code change?  Many thanks Eleventy")*

Hi Nicolas,
I'm sorry, I've missed it!
Thanks a lot!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2MDcwNy1vbmFmdGVyb3JkZXJjb25maXJtLW5vdC10cmlnZ2VyaW5nP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop- Install &amp; Update- Product &amp; Category Display- Content Creation- Sales and Orders- - Orders management- - Reports &amp; Statistics- Customers- Checkout- Payment Methods- Shipping Methods- Import &amp; Export (CSV, XLS…)- Specific Features- - Affilation- - Taxes- - Wishlist- - Vote- - Carousel &amp; Slider- - Mass Actions- - Filters &amp; Search- - Discount &amp; Coupon- - Feature Request- Integrations- Showcase- General Talk about HikaShop- Development- - HikaShop 3.0 Beta- Translation- Commercial Jobs HikaShop Components- HikaMarket- - Market: Feature requests- - Market: How to?- - Market: Bug Report- HikaSerial- - General talk about HikaSerial- - Serial: Bug Report- - Serial: How to?- - Support en Français de HikaSerial (French Support)- - HikaSubscription- HikaAuction- - Auction: Feature requests- - Auction: How to?- - Auction: Bug report Hikashop around the world- Support en Français (French Support)- Russian- - FAQ. Курс выживания с Hikashop. Частые вопросы и о- - Расширения Hikashop- - Наши сайты на Hikashop- 日本語版サポート(Japanese Support)- Thai- German Archives- Bug Report- How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.141 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
