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

#   Custom Payment Method, problem with cancellation of orders

##

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

Less More

- Posts: 47
- Thank you received: 0
-
-

9 years 2 months ago -  9 years 2 months ago [\#276086](#276086) by [brendanlanza](/forum/user/45588-brendanlanza "View brendanlanza's Profile")  *[Custom Payment Method, problem with cancellation of orders](/forum/29-payment-methods/891546-custom-payment-method-problem-with-cancellation-of-orders#276086 "-- url of the page with the problem -- :   biosinar.com  -- HikaShop version -- : 3.1.1 -- Joomla version -- : 3.7.4 -- PHP version -- : 7.0.22  Hi guys,  I am developing a custom payment method for Hikashop. a couple of things are not working.  1. When i use this line in my code for function onPaymentNotification(&amp;$statuses)...  Two things happen ie a) It does NOT change the order status to the defaut for cancellations ie CANCELLED, instead the order remains as CREATED b) It prevent a redirect to the cancel&#95;url, instead the user is brought back to the last stage of the shopping cart  If I replace the same line with this  Everything works, but of course, that line makes cancelled orders become CONFIRMED. It also takes the user to the right cancel&#95;url.  Here's the relevant codes")* was created by *[brendanlanza](/forum/user/45588-brendanlanza "View brendanlanza's Profile")*

-- url of the page with the problem -- : [ biosinar.com](http://biosinar.com)
-- HikaShop version -- : 3.1.1
-- Joomla version -- : 3.7.4
-- PHP version -- : 7.0.22

Hi guys,

I am developing a custom payment method for Hikashop. a couple of things are not working.

1. When i use this line in my code for function onPaymentNotification(&amp;$statuses)...
Code:

$this-&gt;modifyOrder($order_id, $this-&gt;payment_params-&gt;invalid_status, true, true);

Two things happen ie
a) It does NOT change the order status to the defaut for cancellations ie CANCELLED, instead the order remains as CREATED
b) It prevent a redirect to the cancel_url, instead the user is brought back to the last stage of the shopping cart

If I replace the same line with this

> //$this-&gt;modifyOrder($order\_id, $this-&gt;payment\_params-&gt;verified\_status, true, true);

Everything works, but of course, that line makes cancelled orders become CONFIRMED. It also takes the user to the right cancel_url.

Here's the relevant codes Code:

if($vars['EXECCODE'] != 0000) { // Here we display debug information which will be catched by HikaShop and stored in the payment log file available in the configuration's Files section. //print "EXECCODE is non-zero"; if($this-&gt;payment_params-&gt;debug) print 'payment '.$vars['MESSAGE']."\n\n\n"; // This function modifies the order with the id $order_id, to attribute it the status invalid_status. //$this-&gt;modifyOrder($order_id, $this-&gt;payment_params-&gt;verified_status, true, true); $this-&gt;modifyOrder($order_id, $this-&gt;payment_params-&gt;invalid_status, true, true); //To redirect the user, if needed. Here the redirection is useless : we are on server side (and not user side, so the redirect won't work), and the cancel url has been set on the payment platform merchant account $this-&gt;app-&gt;redirect($cancel_url); return false; } //If everything's OK, the payment has been done. Order is validated -&gt; success else { //print "All OK"; $this-&gt;modifyOrder($order_id, $this-&gt;payment_params-&gt;verified_status, true, true); $this-&gt;app-&gt;redirect($return_url); return true; }

Last edit: 9 years 2 months ago by [Jerome](/forum/user/80-jerome "View Jerome's Profile"). Reason: using [code] tag to display code

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84OTE1NDYtY3VzdG9tLXBheW1lbnQtbWV0aG9kLXByb2JsZW0td2l0aC1jYW5jZWxsYXRpb24tb2Ytb3JkZXJzP3RtcGw9bWFya2Rvd24=) 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?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86363
- Thank you received: 14296
-
-

9 years 2 months ago [\#276092](#276092) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Custom Payment Method, problem with cancellation of orders](/forum/29-payment-methods/891546-custom-payment-method-problem-with-cancellation-of-orders#276092 "-- url of the page with the problem -- :   biosinar.com  -- HikaShop version -- : 3.1.1 -- Joomla version -- : 3.7.4 -- PHP version -- : 7.0.22  Hi guys,  I am developing a custom payment method for Hikashop. a couple of things are not working.  1. When i use this line in my code for function onPaymentNotification(&amp;$statuses)...  Two things happen ie a) It does NOT change the order status to the defaut for cancellations ie CANCELLED, instead the order remains as CREATED b) It prevent a redirect to the cancel&#95;url, instead the user is brought back to the last stage of the shopping cart  If I replace the same line with this  Everything works, but of course, that line makes cancelled orders become CONFIRMED. It also takes the user to the right cancel&#95;url.  Here's the relevant codes")*

Hi,

The modifyOrder function doesn't do any redirection.
It does only two things:
- it saves the new order status by calling the save function of class.order
- it sends the payment notification email to the administrator

If the status is not changed, then either there is a problem with the rest of your code when you test it, or there is another plugin, implementing the onAfterOrderUpdate or onBeforeOrderUpdate triggers (which are called during the saving of the order) which does something it shouldn't.
And more specifically, the onBeforeOrderUpdate trigger has a $do parameter which can cancel the change of the order status. So a plugin can cancel your modification of the order status for some reason.
For example, if you've configured a mass action to change the status of orders that are being cancelled to created, the mass action plugin will be able to cancel you order status change.
Also, if such plugin does a redirect, the redirect stops the processing of the page and anything after the redirect will be skipped.
So if a plugin implementing the onBeforeOrderUpdate trigger does a redirect, it will skip the save of the order and your own redirect.

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

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

Less More

- Posts: 47
- Thank you received: 0
-
-

9 years 2 months ago -  9 years 2 months ago [\#276162](#276162) by [brendanlanza](/forum/user/45588-brendanlanza "View brendanlanza's Profile")  Replied by *[brendanlanza](/forum/user/45588-brendanlanza "View brendanlanza's Profile")* on topic *[Custom Payment Method, problem with cancellation of orders](/forum/29-payment-methods/891546-custom-payment-method-problem-with-cancellation-of-orders#276162 "-- url of the page with the problem -- :   biosinar.com  -- HikaShop version -- : 3.1.1 -- Joomla version -- : 3.7.4 -- PHP version -- : 7.0.22  Hi guys,  I am developing a custom payment method for Hikashop. a couple of things are not working.  1. When i use this line in my code for function onPaymentNotification(&amp;$statuses)...  Two things happen ie a) It does NOT change the order status to the defaut for cancellations ie CANCELLED, instead the order remains as CREATED b) It prevent a redirect to the cancel&#95;url, instead the user is brought back to the last stage of the shopping cart  If I replace the same line with this  Everything works, but of course, that line makes cancelled orders become CONFIRMED. It also takes the user to the right cancel&#95;url.  Here's the relevant codes")*

Thank you Nicholas. After doing some checking, I found out that the following line of code based oncallback in the Example Payment Method does not work and has to be replaced with the second. Then it works.

First, set the return and cancel URLs to make callbacks to
Code:

$qrystr = $_SERVER["QUERY_STRING"]; $actionok = "http://unicomms-emall.com/index.php?option=com_hikashop&amp;ctrl=checkout&amp;task=n"."otify&amp;notif_payment=unicommspayment&amp;tmpl=component&amp;".$qrystr; $actionnok = "http://unicomms-emall.com/index.php?option=com_hikashop&amp;ctrl=order&amp;task=cancel_order&amp;".$qrystr;

Then implement the return value in a GET variable to be returned to the return URL
Code:

if ($_REQUEST["choiceLst"] == "Ok")

Finally, make the callback making sure that both the success and cancel calls be made to the return_url and DO NOT use the Cancel_url Code:

if ($_REQUEST["choiceLst"] == "Ok") { $actionurl = $actionok . '&amp;EXECCODE=0000'; //Signifies that the trasaction is okay } else { $actionurl = $actionok . '&amp;EXECCODE=9999'; //Signifies that the transaction is rejected }

Now it works.

I have now encountered another, different problem but I'll raise another issue on that matter.

Last edit: 9 years 2 months ago by [Jerome](/forum/user/80-jerome "View Jerome's Profile"). Reason: using [code] tag to display code

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84OTE1NDYtY3VzdG9tLXBheW1lbnQtbWV0aG9kLXByb2JsZW0td2l0aC1jYW5jZWxsYXRpb24tb2Ytb3JkZXJzP3RtcGw9bWFya2Rvd24=) 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: 26395
- Thank you received: 4077
-
- [](http://obsi.dev)
-

9 years 2 months ago [\#276165](#276165) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Custom Payment Method, problem with cancellation of orders](/forum/29-payment-methods/891546-custom-payment-method-problem-with-cancellation-of-orders#276165 "-- url of the page with the problem -- :   biosinar.com  -- HikaShop version -- : 3.1.1 -- Joomla version -- : 3.7.4 -- PHP version -- : 7.0.22  Hi guys,  I am developing a custom payment method for Hikashop. a couple of things are not working.  1. When i use this line in my code for function onPaymentNotification(&amp;$statuses)...  Two things happen ie a) It does NOT change the order status to the defaut for cancellations ie CANCELLED, instead the order remains as CREATED b) It prevent a redirect to the cancel&#95;url, instead the user is brought back to the last stage of the shopping cart  If I replace the same line with this  Everything works, but of course, that line makes cancelled orders become CONFIRMED. It also takes the user to the right cancel&#95;url.  Here's the relevant codes")*

Hello,

Please use the **code** tag to post code.
Thank you for your understanding.

---

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

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

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