Ok. Thanks.
This is my 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';
}
}