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

#   Further action after successful payment

##

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

Less More

- Posts: 2
- Thank you received: 0
-
-

13 years 2 months ago [\#118759](#118759) by [anvayatech](/forum/user/26599-anvayatech "View anvayatech's Profile")  *[Further action after successful payment](/forum/31-development/861084-further-action-after-successful-payment#118759 "-- HikaShop version -- : 2.2.0 -- Joomla version -- : 2.5.8 -- PHP version -- : 5.3.2  We are trying to ascertain the best method to call custom code after successful user payment.. The code needs to be called only when the order has successfully paid for. We are selling digital goods and need to setup the user's access via API once he has completed his payment.  As part of that, we also need to either modify the email that goes out to the customer or send another one with the access details.  We looked into the API and there are certain events mentioned like :  onAfterOrderConfirm(&amp;$order,&amp;$methods,$method&#95;id) onAfterOrderUpdate(&amp;$order,&amp;$send&#95;email)  We are not sure if these are called after payment, the document seems to suggest that the orderConfirm method is actually used by the payment plugins to redirect to payment page.  Please advise as to the best approach to achieve this.")* was created by *[anvayatech](/forum/user/26599-anvayatech "View anvayatech's Profile")*

-- HikaShop version -- : 2.2.0
-- Joomla version -- : 2.5.8
-- PHP version -- : 5.3.2

We are trying to ascertain the best method to call custom code after successful user payment.. The code needs to be called only when the order has successfully paid for. We are selling digital goods and need to setup the user's access via API once he has completed his payment.

As part of that, we also need to either modify the email that goes out to the customer or send another one with the access details.

We looked into the API and there are certain events mentioned like :

onAfterOrderConfirm(&amp;$order,&amp;$methods,$method_id)
onAfterOrderUpdate(&amp;$order,&amp;$send_email)

We are not sure if these are called after payment, the document seems to suggest that the orderConfirm method is actually used by the payment plugins to redirect to payment page.

Please advise as to the best approach to achieve this.

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

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26394
- Thank you received: 4078
-
- [](http://obsi.dev)
-

13 years 2 months ago [\#118771](#118771) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Further action after successful payment](/forum/31-development/861084-further-action-after-successful-payment#118771 "-- HikaShop version -- : 2.2.0 -- Joomla version -- : 2.5.8 -- PHP version -- : 5.3.2  We are trying to ascertain the best method to call custom code after successful user payment.. The code needs to be called only when the order has successfully paid for. We are selling digital goods and need to setup the user's access via API once he has completed his payment.  As part of that, we also need to either modify the email that goes out to the customer or send another one with the access details.  We looked into the API and there are certain events mentioned like :  onAfterOrderConfirm(&amp;$order,&amp;$methods,$method&#95;id) onAfterOrderUpdate(&amp;$order,&amp;$send&#95;email)  We are not sure if these are called after payment, the document seems to suggest that the orderConfirm method is actually used by the payment plugins to redirect to payment page.  Please advise as to the best approach to achieve this.")*

Hi,

You have to use both triggers.
Some plugins can check if the payment was made before creating the order and other, creates the order and some time after, the payment is made and the order validated.

In each trigger you have an access to the $order object.
You can access to the value " $order-&gt;order_status " in order to check if the order is "confirmed" or not.
To know if an order is being confirmed, you have to compare the order_status with the old order_status. Code:

$config = hikashop_config(); $confirmed = $config-&gt;get('order_confirmed_status', 'confirmed'); if( !empty($order-&gt;order_status) &amp;&amp; $order-&gt;order_status == $confirmed &amp;&amp; (empty($order-&gt;old-&gt;order_status) &#124;&#124; $order-&gt;order_status != $order-&gt;old-&gt;order_status) ) { // The order is being confirmed. }

Regards,

---

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

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

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

Less More

- Posts: 2
- Thank you received: 0
-
-

13 years 2 months ago [\#118815](#118815) by [anvayatech](/forum/user/26599-anvayatech "View anvayatech's Profile")  Replied by *[anvayatech](/forum/user/26599-anvayatech "View anvayatech's Profile")* on topic *[Further action after successful payment](/forum/31-development/861084-further-action-after-successful-payment#118815 "-- HikaShop version -- : 2.2.0 -- Joomla version -- : 2.5.8 -- PHP version -- : 5.3.2  We are trying to ascertain the best method to call custom code after successful user payment.. The code needs to be called only when the order has successfully paid for. We are selling digital goods and need to setup the user's access via API once he has completed his payment.  As part of that, we also need to either modify the email that goes out to the customer or send another one with the access details.  We looked into the API and there are certain events mentioned like :  onAfterOrderConfirm(&amp;$order,&amp;$methods,$method&#95;id) onAfterOrderUpdate(&amp;$order,&amp;$send&#95;email)  We are not sure if these are called after payment, the document seems to suggest that the orderConfirm method is actually used by the payment plugins to redirect to payment page.  Please advise as to the best approach to achieve this.")*

Hi,

Thanks a lot for a quick and detailed reply. Really appreciate you taking the time out to answer our query.

Some confusion regarding where to put this code. Are we required to create a plugin under HikaShopPayment group extending the HikashopPaymentPlugin ? This is supposed to be a post processing code and not a payment gateway choice, and therefore does not seem correct to put it under HikashopPayment. Are we correct ? Not certain if the events would be triggered if we put it somewhere else.

Please advise.

Regards,

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

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26394
- Thank you received: 4078
-
- [](http://obsi.dev)
-

13 years 2 months ago [\#118835](#118835) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Further action after successful payment](/forum/31-development/861084-further-action-after-successful-payment#118835 "-- HikaShop version -- : 2.2.0 -- Joomla version -- : 2.5.8 -- PHP version -- : 5.3.2  We are trying to ascertain the best method to call custom code after successful user payment.. The code needs to be called only when the order has successfully paid for. We are selling digital goods and need to setup the user's access via API once he has completed his payment.  As part of that, we also need to either modify the email that goes out to the customer or send another one with the access details.  We looked into the API and there are certain events mentioned like :  onAfterOrderConfirm(&amp;$order,&amp;$methods,$method&#95;id) onAfterOrderUpdate(&amp;$order,&amp;$send&#95;email)  We are not sure if these are called after payment, the document seems to suggest that the orderConfirm method is actually used by the payment plugins to redirect to payment page.  Please advise as to the best approach to achieve this.")*

Hi,

You have to use this code in an HikaShop plugin. No necessary a payment plugin, you can just create a classical JPlugin under the group "hikashop".
**onAfterOrderConfirm** is a special payment trigger which is call only for the selected payment method.
You can use **onAfterOrderCreate** and **onAfterOrderUpdate** in a classical hikashop plugin without any problem.

If you want to create your own payment plugin, using a structure based on HikashopPaymentPlugin will be useful because all the generic tasks for payments are already there (same thing for shipping plugins and HikashopShippingPlugin).

Regards,

---

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2MTA4NC1mdXJ0aGVyLWFjdGlvbi1hZnRlci1zdWNjZXNzZnVsLXBheW1lbnQ/dG1wbD1tYXJrZG93bg==) 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.102 seconds

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

[](#top)
