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

#   Help for developing a new payment method

##

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

Less More

- Posts: 14
- Thank you received: 0
-
-

12 years 3 months ago [\#166639](#166639) by [willylord](/forum/user/31332-willylord "View willylord's Profile")  *[Help for developing a new payment method](/forum/29-payment-methods/870223-help-for-developing-a-new-payment-method#166639 "-- Joomla version -- : 2.5.20 -- PHP version -- : 5.3.4  Hi, I'm going to creating a new payment plugin.  My problem is the variable $order-&gt;order&#95;id that it's always empty in my array!  For example, if I can try to pay using Paypal (using pluigin default), the payment it works fine, but the variable $order-&gt;order&#95;id is always empty.  Can you help me to solve this problem?  Thank you")* was created by *[willylord](/forum/user/31332-willylord "View willylord's Profile")*

-- Joomla version -- : 2.5.20
-- PHP version -- : 5.3.4

Hi,
I'm going to creating a new payment plugin.

My problem is the variable $order-&gt;order_id that it's always empty in my array!

For example, if I can try to pay using Paypal (using pluigin default), the payment it works fine, but the variable $order-&gt;order_id is always empty.

Can you help me to solve this problem?

Thank you

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

12 years 3 months ago [\#166644](#166644) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Help for developing a new payment method](/forum/29-payment-methods/870223-help-for-developing-a-new-payment-method#166644 "-- Joomla version -- : 2.5.20 -- PHP version -- : 5.3.4  Hi, I'm going to creating a new payment plugin.  My problem is the variable $order-&gt;order&#95;id that it's always empty in my array!  For example, if I can try to pay using Paypal (using pluigin default), the payment it works fine, but the variable $order-&gt;order&#95;id is always empty.  Can you help me to solve this problem?  Thank you")*

Hi,

You can't have an order id if the order is not already created, like in the trigger onBeforeOrderCreated.

Regards,

---

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

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

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

Less More

- Posts: 14
- Thank you received: 0
-
-

12 years 3 months ago -  12 years 3 months ago [\#166677](#166677) by [willylord](/forum/user/31332-willylord "View willylord's Profile")  Replied by *[willylord](/forum/user/31332-willylord "View willylord's Profile")* on topic *[Help for developing a new payment method](/forum/29-payment-methods/870223-help-for-developing-a-new-payment-method#166677 "-- Joomla version -- : 2.5.20 -- PHP version -- : 5.3.4  Hi, I'm going to creating a new payment plugin.  My problem is the variable $order-&gt;order&#95;id that it's always empty in my array!  For example, if I can try to pay using Paypal (using pluigin default), the payment it works fine, but the variable $order-&gt;order&#95;id is always empty.  Can you help me to solve this problem?  Thank you")*

Ok. Thanks.

This is my code: Code:

&lt;?php /** * @package HikaShop for Joomla! * @version 2.2.3 * @author hikashop.com * @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?&gt;&lt;?php class plgHikashoppaymentmonetaweb2 extends hikashopPaymentPlugin { var $accepted_currencies = array('EUR'); var $multiple = true; var $name = 'superpay'; var $pluginConfig = array( 'username' =&gt; array('Terminal ID', 'input'), 'password' =&gt; array('Terminal password', 'input'), 'domain_name' =&gt; array('Main domain name&lt;br&gt;&lt;small&gt;(i.e.: http://www.myshop.net)&lt;/small&gt;', 'input', 'http://www.myshop.net'), 'debug' =&gt; array('Test environment', 'boolean', '1') ); function onBeforeOrderCreate(&amp;$order, &amp;$do) { if(parent::onBeforeOrderCreate($order, $do) === true) return true; $this-&gt;ccLoad(); $amount = number_format($order-&gt;cart-&gt;full_total-&gt;prices[0]-&gt;price_value_with_tax,2,'.',''); $domain=$this-&gt;payment_params-&gt;domain_name; $pluginPath=$domain."/plugins/hikashoppayment/superpay/"; /* ORDER CODE ??? */ $theOrderCode=$order-&gt;order_id; $host="test"; /* Start the source code MY PERSONAL BANK */ $parameters = array( 'id' =&gt; $this-&gt;payment_params-&gt;username, 'password' =&gt; $this-&gt;payment_params-&gt;password, 'operationType' =&gt; 'initialize', 'amount' =&gt; $amount, 'currencyCode' =&gt; '978', 'language' =&gt; 'ITA', 'responseToMerchantUrl' =&gt; $pluginPath.'superpay_notify.php', 'recoveryUrl' =&gt; $pluginPath.'superpay_recovery.php', 'merchantOrderId' =&gt; 'Order Num. '.$theOrderCode, // ??? ORDER CODE ??? 'cardHolderName' =&gt; '', 'cardHolderEmail' =&gt; '', 'description' =&gt; '', 'customField' =&gt; '' ); if(!function_exists('curl_init')){ $this-&gt;app-&gt;enqueueMessage('The MonetaWeb2 payment plugin needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.','error'); return false; } $curlHandle = curl_init(); curl_setopt($curlHandle, CURLOPT_URL, 'https://'.$host.'.monetaonline.it/monetaweb/payment/2/xml'); curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlHandle, CURLOPT_POST, true); curl_setopt($curlHandle, CURLOPT_POSTFIELDS, http_build_query($parameters)); $xmlResponse = curl_exec($curlHandle); curl_close($curlHandle); $response = new SimpleXMLElement($xmlResponse); $paymentId = $response-&gt;paymentid; $paymentUrl = $response-&gt;hostedpageurl; $securityToken = $response-&gt;securitytoken; $setefiPaymentPageUrl = "$paymentUrl?PaymentID=$paymentId"; // print_r($parameters); exit(); header("Location: $setefiPaymentPageUrl"); } function onAfterOrderConfirm(&amp;$order,&amp;$methods,$method_id){ parent::onAfterOrderConfirm($order, $methods, $method_id); $this-&gt;removeCart = true; return $this-&gt;showPage('thanks'); } function getPaymentDefaultValues(&amp;$element) { $element-&gt;payment_name='Credit Card'; $element-&gt;payment_description='You can pay by credit card using this payment method'; $element-&gt;payment_images='MasterCard,VISA,American_Express'; $element-&gt;payment_params-&gt;username=''; $element-&gt;payment_params-&gt;password=''; $element-&gt;payment_params-&gt;ask_ccv = true; $element-&gt;payment_params-&gt;ask_owner = false; $element-&gt;payment_params-&gt;verified_status='confirmed'; } }

Can you help me to debug it, for getting correctly the order_id ?
In which one fuction it can be generated?

Thanks!

Last edit: 12 years 3 months ago by [willylord](/forum/user/31332-willylord "View willylord's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84NzAyMjMtaGVscC1mb3ItZGV2ZWxvcGluZy1hLW5ldy1wYXltZW50LW1ldGhvZD90bXBsPW1hcmtkb3du) 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: 86593
- Thank you received: 14334
-
-

12 years 3 months ago [\#166728](#166728) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Help for developing a new payment method](/forum/29-payment-methods/870223-help-for-developing-a-new-payment-method#166728 "-- Joomla version -- : 2.5.20 -- PHP version -- : 5.3.4  Hi, I'm going to creating a new payment plugin.  My problem is the variable $order-&gt;order&#95;id that it's always empty in my array!  For example, if I can try to pay using Paypal (using pluigin default), the payment it works fine, but the variable $order-&gt;order&#95;id is always empty.  Can you help me to solve this problem?  Thank you")*

Hi,

It's normal that the order_id is not available in $order since the function onBeforeOrderCreate is called before the order is created and thus no order_id has yet been assigned to it.

You should instead put your code in the onAfterOrderConfirm function, like in the PayPal plugin.

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

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

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

Less More

- Posts: 14
- Thank you received: 0
-
-

12 years 3 months ago [\#166759](#166759) by [willylord](/forum/user/31332-willylord "View willylord's Profile")  Replied by *[willylord](/forum/user/31332-willylord "View willylord's Profile")* on topic *[Help for developing a new payment method](/forum/29-payment-methods/870223-help-for-developing-a-new-payment-method#166759 "-- Joomla version -- : 2.5.20 -- PHP version -- : 5.3.4  Hi, I'm going to creating a new payment plugin.  My problem is the variable $order-&gt;order&#95;id that it's always empty in my array!  For example, if I can try to pay using Paypal (using pluigin default), the payment it works fine, but the variable $order-&gt;order&#95;id is always empty.  Can you help me to solve this problem?  Thank you")*

Thanks.
In the onAfterOrderConfirm() it works fine.

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

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

Less More

- Posts: 4
- Thank you received: 0
-
-

9 years 4 months ago [\#275118](#275118) by [VIAGGIOINGIAPPONE](/forum/user/51576-viaggioingiappone "View VIAGGIOINGIAPPONE's Profile")  Replied by *[VIAGGIOINGIAPPONE](/forum/user/51576-viaggioingiappone "View VIAGGIOINGIAPPONE's Profile")* on topic *[Help for developing a new payment method](/forum/29-payment-methods/870223-help-for-developing-a-new-payment-method#275118 "-- Joomla version -- : 2.5.20 -- PHP version -- : 5.3.4  Hi, I'm going to creating a new payment plugin.  My problem is the variable $order-&gt;order&#95;id that it's always empty in my array!  For example, if I can try to pay using Paypal (using pluigin default), the payment it works fine, but the variable $order-&gt;order&#95;id is always empty.  Can you help me to solve this problem?  Thank you")*

hi... i need to use this payment method...
can you help me?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI5LXBheW1lbnQtbWV0aG9kcy84NzAyMjMtaGVscC1mb3ItZGV2ZWxvcGluZy1hLW5ldy1wYXltZW50LW1ldGhvZD90bXBsPW1hcmtkb3du) 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: 86593
- Thank you received: 14334
-
-

9 years 4 months ago [\#275120](#275120) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Help for developing a new payment method](/forum/29-payment-methods/870223-help-for-developing-a-new-payment-method#275120 "-- Joomla version -- : 2.5.20 -- PHP version -- : 5.3.4  Hi, I'm going to creating a new payment plugin.  My problem is the variable $order-&gt;order&#95;id that it's always empty in my array!  For example, if I can try to pay using Paypal (using pluigin default), the payment it works fine, but the variable $order-&gt;order&#95;id is always empty.  Can you help me to solve this problem?  Thank you")*

Hi,

We don't have the full code of the plugin on our end so we can't help.
However, maybe @willylord could provide it ?

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

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