- Posts: 14
- Thank you received: 0
Help for developing a new payment method
12 years 1 month ago #166639
by willylord
Help for developing a new payment method was created by willylord
-- 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->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->order_id is always empty.
Can you help me to solve this problem?
Thank you
-- PHP version -- : 5.3.4
Hi,
I'm going to creating a new payment plugin.
My problem is the variable $order->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->order_id is always empty.
Can you help me to solve this problem?
Thank you
Please Log in or Create an account to join the conversation.
12 years 1 month ago #166644
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Help for developing a new payment method
Hi,
You can't have an order id if the order is not already created, like in the trigger onBeforeOrderCreated.
Regards,
You can't have an order id if the order is not already created, like in the trigger onBeforeOrderCreated.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
12 years 1 month ago - 12 years 1 month ago #166677
by willylord
Replied by willylord on topic Help for developing a new payment method
Ok. Thanks.
This is my code:
Can you help me to debug it, for getting correctly the order_id ?
In which one fuction it can be generated?
Thanks!
This is my code:
Code:
<?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');
?><?php
class plgHikashoppaymentmonetaweb2 extends hikashopPaymentPlugin
{
var $accepted_currencies = array('EUR');
var $multiple = true;
var $name = 'superpay';
var $pluginConfig = array(
'username' => array('Terminal ID', 'input'),
'password' => array('Terminal password', 'input'),
'domain_name' => array('Main domain name<br><small>(i.e.: http://www.myshop.net)</small>', 'input', 'http://www.myshop.net'),
'debug' => array('Test environment', 'boolean', '1')
);
function onBeforeOrderCreate(&$order, &$do) {
if(parent::onBeforeOrderCreate($order, $do) === true)
return true;
$this->ccLoad();
$amount = number_format($order->cart->full_total->prices[0]->price_value_with_tax,2,'.','');
$domain=$this->payment_params->domain_name;
$pluginPath=$domain."/plugins/hikashoppayment/superpay/";
/* ORDER CODE ??? */
$theOrderCode=$order->order_id;
$host="test";
/* Start the source code MY PERSONAL BANK */
$parameters = array(
'id' => $this->payment_params->username,
'password' => $this->payment_params->password,
'operationType' => 'initialize',
'amount' => $amount,
'currencyCode' => '978',
'language' => 'ITA',
'responseToMerchantUrl' => $pluginPath.'superpay_notify.php',
'recoveryUrl' => $pluginPath.'superpay_recovery.php',
'merchantOrderId' => 'Order Num. '.$theOrderCode, // ??? ORDER CODE ???
'cardHolderName' => '',
'cardHolderEmail' => '',
'description' => '',
'customField' => ''
);
if(!function_exists('curl_init')){
$this->app->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->paymentid;
$paymentUrl = $response->hostedpageurl;
$securityToken = $response->securitytoken;
$setefiPaymentPageUrl = "$paymentUrl?PaymentID=$paymentId";
// print_r($parameters); exit();
header("Location: $setefiPaymentPageUrl");
}
function onAfterOrderConfirm(&$order,&$methods,$method_id){
parent::onAfterOrderConfirm($order, $methods, $method_id);
$this->removeCart = true;
return $this->showPage('thanks');
}
function getPaymentDefaultValues(&$element) {
$element->payment_name='Credit Card';
$element->payment_description='You can pay by credit card using this payment method';
$element->payment_images='MasterCard,VISA,American_Express';
$element->payment_params->username='';
$element->payment_params->password='';
$element->payment_params->ask_ccv = true;
$element->payment_params->ask_owner = false;
$element->payment_params->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 1 month ago by willylord.
Please Log in or Create an account to join the conversation.
12 years 1 month ago #166728
by nicolas
Replied by nicolas on topic Help for developing a new payment method
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.
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
Please Log in or Create an account to join the conversation.
12 years 1 month ago #166759
by willylord
Replied by willylord on topic Help for developing a new payment method
Thanks.
In the onAfterOrderConfirm() it works fine.
In the onAfterOrderConfirm() it works fine.
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 4
- Thank you received: 0
9 years 2 months ago #275118
by VIAGGIOINGIAPPONE
Replied by VIAGGIOINGIAPPONE on topic Help for developing a new payment method
hi... i need to use this payment method...
can you help me?
can you help me?
Please Log in or Create an account to join the conversation.
9 years 2 months ago #275120
by nicolas
Replied by nicolas on topic Help for developing a new payment method
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 ?
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 or Create an account to join the conversation.
Time to create page: 0.192 seconds