MONERIS.PHP
<?phpclass ControllerExtensionPaymentMoneris extends Controller { public function index() { $this->load->language('extension/payment/moneris'); $this->load->model('extension/payment/moneris');
if($this->config->get('payment_moneris_environment') == 'live') { $data['publishable_key'] = $this->config->get('payment_moneris_live_publishable_key'); } else { $data['publishable_key'] = $this->config->get('payment_moneris_test_publishable_key'); }
$data['text_credit_card'] = $this->language->get('text_credit_card'); $data['text_start_date'] = $this->language->get('text_start_date'); $data['text_wait'] = $this->language->get('text_wait'); $data['text_loading'] = $this->language->get('text_loading');
$data['entry_cc_type'] = $this->language->get('entry_cc_type'); $data['entry_cc_number'] = $this->language->get('entry_cc_number'); $data['entry_cc_start_date'] = $this->language->get('entry_cc_start_date'); $data['entry_cc_expire_date'] = $this->language->get('entry_cc_expire_date'); $data['entry_cc_cvv2'] = $this->language->get('entry_cc_cvv2'); $data['entry_cc_issue'] = $this->language->get('entry_cc_issue');
$data['help_start_date'] = $this->language->get('help_start_date'); $data['help_issue'] = $this->language->get('help_issue');
$data['button_confirm'] = $this->language->get('button_confirm');
$data['can_store_cards'] = ($this->customer->isLogged() && $this->config->get('payment_moneris_store_cards')); $data['cards'] = [];
if($this->customer->isLogged() && $this->config->get('payment_moneris_store_cards')) { $data['cards'] = $this->model_extension_payment_moneris->getCards($this->customer->getId()); }
return $this->load->view('extension/payment/moneris', $data); }
public function send() { $json = array();
//$this->load->library('mpgClasses'); try { include_once(DIR_SYSTEM . 'library/mpgClasses.php'); $this->load->model('checkout/order'); $this->load->model('account/customer'); $this->load->model('extension/payment/moneris');
$moneris_store_key = $this->config->get('payment_moneris_store_key'); $moneris_token_key = $this->config->get('payment_moneris_token_key'); $moneris_environment = $this->config->get('payment_moneris_environment'); $moneris_currency = $this->config->get('payment_moneris_currency'); $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); $orderAuthkey=$this->rand_str(); $store_id=$moneris_store_key;//'store5'; $api_token=$moneris_token_key;//'yesguy'; $acc = $moneris_environment;//'prod';//test //print_r($order_info);die(); $type='purchase'; $cust_id=$order_info['customer_id']; $order_id=$order_info['order_id']; $amount=$order_info['total']; $pan=$_REQUEST['number']; $expiry_date=trim($_REQUEST['exp_year']).trim($_REQUEST['exp_month']); $crypt='7'; $dynamic_descriptor=$_REQUEST['cvc']; $status_check = 'false';
/************************** CVD Variables *****************************/ $cvd_indicator = '1'; $cvd_value = '198';
/********************** AVS Associative Array *************************/ $avsTemplate = array( 'avs_street_number'=>'', 'avs_street_name' =>$order_info['payment_address_1'], 'avs_zipcode' => $order_info['payment_postcode'] ); /********************** CVD Associative Array *************************/
$cvdTemplate = array('cvd_indicator' => $cvd_indicator,'cvd_value' => $cvd_value);
$mpgAvsInfo = new mpgAvsInfo ($avsTemplate);$mpgCvdInfo = new mpgCvdInfo ($cvdTemplate);
$txnArray=array('type'=>$type, 'order_id'=>$order_id.'|'.date('Y-m-d H:i:s'), 'cust_id'=>$cust_id, 'amount'=>number_format($amount, 2, '.', ''), 'pan'=>$pan, 'expdate'=>$expiry_date, 'crypt_type'=>$crypt, 'dynamic_descriptor'=>$dynamic_descriptor ); //print_r($txnArray);die(); $mpgTxn = new mpgTransaction($txnArray);
$mpgTxn->setAvsInfo($mpgAvsInfo);$mpgTxn->setCvdInfo($mpgCvdInfo);
$mpgRequest = new mpgRequest($mpgTxn); //$mpgRequest->setProcCountryCode($moneris_currency); //echo "<pre>";print_r($mpgRequest);//die(); $mpgHttpPost =new mpgHttpsPost($store_id,$api_token,$mpgRequest,$acc); //echo "<pre>";print_r($mpgHttpPost); $mpgResponse=$mpgHttpPost->getMpgResponse(); //echo "<pre>";print_r($mpgResponse);die(); if (!empty($mpgResponse) && isset($mpgResponse->responseData['Message']) && strpos($mpgResponse->responseData['Message'], 'APPROVED') !== false) { $TxnNumber = $mpgResponse->responseData['TransID']; $sqlmon="INSERT INTO moneris_pay_log (`order_id`,`tran_id`,`status`,`response`) VALUES ('".$order_id."','".$TxnNumber."','APPROVED','".serialize($mpgResponse->responseData)."')"; $this->model_extension_payment_moneris->addOrder($order_info, $TxnNumber, serialize($mpgResponse->responseData)); $message = 'Txn Number: '.$TxnNumber.' Status: APPROVED'; $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('payment_moneris_order_status_id'), $message, false); $json['processed'] = true; $json['success'] = $this->url->link('checkout/success'); }else{ $TxnNumber = '';//$mpgResponse->responseData['TransID']; $sqlmon="INSERT INTO moneris_pay_log (`order_id`,`tran_id`,`status`,`response`) VALUES ('".$order_id."','".$TxnNumber."','ERROR','".serialize($mpgResponse->responseData)."')"; //$this->model_extension_payment_moneris->addOrder($order_info, $TxnNumber, serialize($mpgResponse->responseData)); file_put_contents('moneriserror.txt',print_r($mpgResponse,1)); mail('phpscript3@gmail.com','moneris',print_r($mpgResponse,1)); $json['error'] = 'Txn Number : '.$TxnNumber.' '.$mpgResponse->responseData['Message']; } } catch (exception $e) { file_put_contents('Moneris error',print_r($e,1)); }
$this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); } private function rand_str($length = 32, $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890'){ // Length of character list $chars_length = (strlen($chars) - 1);
// Start our string $string = $chars{rand(0, $chars_length)}; // Generate random string for ($i = 1; $i < $length; $i = strlen($string)) { // Grab a random character from our list $r = $chars{rand(0, $chars_length)}; // Make sure the same two characters don't appear next to each other if ($r != $string{$i - 1}) $string .= $r; } // Return the string return $string;}
private function initStripe() { $this->load->library('moneris'); if($this->config->get('payment_moneris_environment') == 'live') { $moneris_secret_key = $this->config->get('payment_moneris_live_secret_key'); } else { $moneris_secret_key = $this->config->get('payment_moneris_test_secret_key'); }
if($moneris_secret_key != '' && $moneris_secret_key != null) { \Stripe\Stripe::setApiKey($moneris_secret_key); return true; }
return false;
}}
mpgClasses.php
<?php
#################### mpgGlobals (Canada Moneris) ###########################################
class mpgGlobals{
var $Globals=array( 'MONERIS_PROTOCOL' => 'https', 'MONERIS_HOST' => 'esqa.moneris.com', 'MONERIS_PORT' =>'443', 'MONERIS_FILE' => '/gateway2/servlet/MpgRequest', 'API_VERSION' =>'MpgApi Version 2.03(php)', 'CLIENT_TIMEOUT' => '60' );
function __construct() { // default }
function getGlobals() { return($this->Globals); }
}//end class mpgGlobals
###################### mpgHttpsPost #########################################
class mpgHttpsPost{
var $api_token; var $store_id; var $mpgRequest; var $mpgResponse;
function __construct($store_id,$api_token,$mpgRequestOBJ, $log = false) {
$this->store_id=$store_id; $this->api_token= $api_token; $this->mpgRequest=$mpgRequestOBJ; $dataToSend=$this->toXML();
//do post
$g=new mpgGlobals(); $gArray=$g->getGlobals();
// Qphoria Added for automatic test/prod mode switch if ($this->store_id == 'store1' || $this->store_id == 'store2' || $this->store_id == 'store3' || $this->store_id == 'store5') { $gArray['MONERIS_HOST'] = 'esqa.moneris.com'; //test CA } else { $gArray['MONERIS_HOST'] = 'www3.moneris.com'; //prod CA }//
$url=$gArray['MONERIS_PROTOCOL']."://". $gArray['MONERIS_HOST'].":". $gArray['MONERIS_PORT']. $gArray['MONERIS_FILE'];
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,$dataToSend); curl_setopt($ch,CURLOPT_TIMEOUT,$gArray['CLIENT_TIMEOUT']); curl_setopt($ch,CURLOPT_USERAGENT,$gArray['API_VERSION']); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response=curl_exec ($ch);
curl_close ($ch);
if ($log) { $dataToSend = preg_replace('#<pan>(.+)</pan>#', '<pan>xxxxxxxxxxxxxxxx</pan>', $dataToSend); $dataToSend = preg_replace('#<expdate>(.+)</expdate>#', '<expdate>xxxx</expdate>', $dataToSend); file_put_contents($log, "\r\n--------\r\nRAWDUMP:\r\nURL: $url\r\nREQ:$dataToSend \r\nRESP:$response\r\n--------------\r\n", FILE_APPEND); }
//echo "RESPONSE = $response\n\n";
if(!$response) {
$response="<?xml version=\"1.0\"?><response><receipt>". "<ReceiptId>Global Error Receipt</ReceiptId>". "<ReferenceNum>null</ReferenceNum><ResponseCode>null</ResponseCode>". "<ISO>null</ISO> <AuthCode>null</AuthCode><TransTime>null</TransTime>". "<TransDate>null</TransDate><TransType>null</TransType><Complete>false</Complete>". "<Message>null</Message><TransAmount>null</TransAmount>". "<CardType>null</CardType>". "<TransID>null</TransID><TimedOut>null</TimedOut>". "</receipt></response>"; }
$this->mpgResponse=new mpgResponse($response);
}
function getMpgResponse() { return $this->mpgResponse;
function toXML( ) {
$req=$this->mpgRequest ; $reqXMLString=$req->toXML(); $xmlString=''; $xmlString .="<?xml version=\"1.0\"?>". "<request>". "<store_id>$this->store_id</store_id>". "<api_token>$this->api_token</api_token>". $reqXMLString. "</request>";
return ($xmlString);
}//end class mpgHttpsPost
############# mpgResponse #####################################################
class mpgResponse{
var $responseData;
var $p; //parser
var $currentTag; var $purchaseHash = array(); var $refundHash; var $correctionHash = array(); var $isBatchTotals; var $term_id; var $receiptHash = array(); var $ecrHash = array(); var $CardType; var $currentTxnType; var $ecrs = array(); var $cards = array(); var $cardHash= array();
var $ACSUrl;
function __construct($xmlString) { $this->p = xml_parser_create(); xml_parser_set_option($this->p,XML_OPTION_CASE_FOLDING,0); xml_parser_set_option($this->p,XML_OPTION_TARGET_ENCODING,"UTF-8"); xml_set_object($this->p,$this); xml_set_element_handler($this->p,"startHandler","endHandler"); xml_set_character_data_handler($this->p,"characterHandler"); xml_parse($this->p,$xmlString); xml_parser_free($this->p);
}//end of constructor
function getMpgResponseData(){ return($this->responseData); }
function getAvsResultCode() { return ($this->responseData['AvsResultCode']);}
function getCvdResultCode() { return ($this->responseData['CvdResultCode']);}
function getRecurSuccess(){ return ($this->responseData['RecurSuccess']);}
function getCardType(){ return ($this->responseData['CardType']);}
function getTransAmount(){ return ($this->responseData['TransAmount']);}
function getTxnNumber(){ return ($this->responseData['TransID']);}
function getReceiptId(){ return ($this->responseData['ReceiptId']);}
function getTransType(){ return ($this->responseData['TransType']);}
function getReferenceNum(){ return ($this->responseData['ReferenceNum']);}
function getResponseCode(){ return ($this->responseData['ResponseCode']);}
function getISO(){ return ($this->responseData['ISO']);}
function getBankTotals(){ return ($this->responseData['BankTotals']);}
function getMessage(){ return ($this->responseData['Message']);}
function getAuthCode(){ return ($this->responseData['AuthCode']);}
function getComplete(){ return ($this->responseData['Complete']);}
function getTransDate(){ return ($this->responseData['TransDate']);}
function getTransTime(){ return ($this->responseData['TransTime']);}
function getTicket(){ return ($this->responseData['Ticket']);}
function getTimedOut(){ return ($this->responseData['TimedOut']);}
function getRecurUpdateSuccess(){ return ($this->responseData['RecurUpdateSuccess']);}
function getNextRecurDate(){ return ($this->responseData['NextRecurDate']);}
function getRecurEndDate(){ return ($this->responseData['RecurEndDate']);}
function getTerminalStatus($ecr_no){ return ($this->ecrHash[$ecr_no]);}
function getPurchaseAmount($ecr_no,$card_type){
return ($this->purchaseHash[$ecr_no][$card_type]['Amount']=="" ? 0:$this->purchaseHash[$ecr_no][$card_type]['Amount']);}
function getPurchaseCount($ecr_no,$card_type){
return ($this->purchaseHash[$ecr_no][$card_type]['Count']=="" ? 0:$this->purchaseHash[$ecr_no][$card_type]['Count']);}
function getRefundAmount($ecr_no,$card_type){
return ($this->refundHash[$ecr_no][$card_type]['Amount']=="" ? 0:$this->refundHash[$ecr_no][$card_type]['Amount']);}
function getRefundCount($ecr_no,$card_type){
return ($this->refundHash[$ecr_no][$card_type]['Count']=="" ? 0:$this->refundHash[$ecr_no][$card_type]['Count']);}
function getCorrectionAmount($ecr_no,$card_type){
return ($this->correctionHash[$ecr_no][$card_type]['Amount']=="" ? 0:$this->correctionHash[$ecr_no][$card_type]['Amount']);}
function getCorrectionCount($ecr_no,$card_type){
return ($this->correctionHash[$ecr_no][$card_type]['Count']=="" ? 0:$this->correctionHash[$ecr_no][$card_type]['Count']);}
function getTerminalIDs(){ return ($this->ecrs);}
function getCreditCardsAll(){ return (array_keys($this->cards));}
function getCreditCards($ecr_no){ return ($this->cardHash[$ecr_no]);}
function characterHandler($parser,$data){
if($this->isBatchTotals) { switch($this->currentTag) { case "term_id" : { $this->term_id=$data; array_push($this->ecrs,$this->term_id); $this->cardHash[$data]=array(); break; }
case "closed" : { $ecrHash=$this->ecrHash; $ecrHash[$this->term_id]=$data; $this->ecrHash = $ecrHash; break; }
case "CardType" : { $this->CardType=$data; $this->cards[$data]=$data; array_push($this->cardHash[$this->term_id],$data) ; break; }
case "Amount" : { if($this->currentTxnType == "Purchase") { $this->purchaseHash[$this->term_id][$this->CardType]['Amount']=$data; } else if( $this->currentTxnType == "Refund") { $this->refundHash[$this->term_id][$this->CardType]['Amount']=$data; }
else if( $this->currentTxnType == "Correction") { $this->correctionHash[$this->term_id][$this->CardType]['Amount']=$data; } break; }
case "Count" : { if($this->currentTxnType == "Purchase") { $this->purchaseHash[$this->term_id][$this->CardType]['Count']=$data; } else if( $this->currentTxnType == "Refund") { $this->refundHash[$this->term_id][$this->CardType]['Count']=$data;
else if( $this->currentTxnType == "Correction") { $this->correctionHash[$this->term_id][$this->CardType]['Count']=$data; } break; } } } else {
if (isset($this->responseData[$this->currentTag])) { $this->responseData[$this->currentTag] .=$data; } else { $this->responseData[$this->currentTag] =$data; } }
}//end characterHandler
function startHandler($parser,$name,$attrs){
$this->currentTag=$name;
if($this->currentTag == "BankTotals") { $this->isBatchTotals=1; } else if($this->currentTag == "Purchase") { $this->purchaseHash[$this->term_id][$this->CardType]=array(); $this->currentTxnType="Purchase"; } else if($this->currentTag == "Refund") { $this->refundHash[$this->term_id][$this->CardType]=array(); $this->currentTxnType="Refund"; } else if($this->currentTag == "Correction") { $this->correctionHash[$this->term_id][$this->CardType]=array(); $this->currentTxnType="Correction"; }
function endHandler($parser,$name){
$this->currentTag=$name; if($name == "BankTotals") { $this->isBatchTotals=0; }
$this->currentTag="/dev/null";}
}//end class mpgResponse
################## mpgRequest ###########################################################
class mpgRequest{
var $txnTypes =array('purchase'=> array('order_id','cust_id', 'amount', 'pan', 'expdate', 'crypt_type'), 'refund' => array('order_id', 'amount', 'txn_number', 'crypt_type'), 'idebit_purchase'=>array('order_id', 'cust_id', 'amount','idebit_track2'), 'idebit_refund'=>array('order_id','amount','txn_number'), 'purchase_reversal'=>array('order_id','amount'), 'refund_reversal'=>array('order_id','amount'), 'ind_refund' => array('order_id','cust_id', 'amount','pan','expdate', 'crypt_type'), 'preauth' =>array('order_id','cust_id', 'amount', 'pan', 'expdate', 'crypt_type'), 'completion' => array('order_id', 'comp_amount','txn_number', 'crypt_type'), 'purchasecorrection' => array('order_id', 'txn_number', 'crypt_type'), 'opentotals' => array('ecr_number'), 'batchclose' => array('ecr_number'), 'cavv_purchase'=> array('order_id','cust_id', 'amount', 'pan', 'expdate', 'cavv'), 'cavv_preauth' =>array('order_id','cust_id', 'amount', 'pan', 'expdate', 'cavv'), 'recur_update' => array('order_id', 'cust_id', 'pan', 'expdate', 'recur_amount', 'add_num_recurs', 'total_num_recurs', 'hold', 'terminate')
);var $txnArray;
function __construct($txn){
if(is_array($txn)) { $txn=$txn[0]; }
$this->txnArray=$txn;
function toXML(){
$tmpTxnArray=$this->txnArray;
$txnArrayLen=count( (array) $tmpTxnArray); //total number of transactions $txnObj=$tmpTxnArray;
$txn=$txnObj->getTransaction(); //call to a non-member function $txnType=array_shift($txn); $tmpTxnTypes=$this->txnTypes; $txnTypeArray=$tmpTxnTypes[$txnType]; $txnTypeArrayLen=count($txnTypeArray); //length of a specific txn type
$txnXMLString=""; for($i=0;$i < $txnTypeArrayLen ;$i++) { $txnXMLString .="<$txnTypeArray[$i]>" //begin tag .$txn[$txnTypeArray[$i]] // data . "</$txnTypeArray[$i]>"; //end tag }
$txnXMLString = "<$txnType>$txnXMLString";
$recur = $txnObj->getRecur(); if($recur != null) { $txnXMLString .= $recur->toXML(); }/* $avsInfo = $txnObj->getAvsInfo(); if($avsInfo != null) { $txnXMLString .= $avsInfo->toXML(); }
$cvdInfo = $txnObj->getCvdInfo(); if($cvdInfo != null) { $txnXMLString .= $cvdInfo->toXML(); }*/ $avsInfo = $txnObj->getAvsInfo(); if($avsInfo != null) { $mpgAvsInfo = new mpgAvsInfo($avsInfo); $txnXMLString .= $mpgAvsInfo->toXML(); } $cvdInfo = $txnObj->getCvdInfo(); //print_r($cvdInfo);die(); if($cvdInfo != null) { $mpgCvdInfo = new mpgCvdInfo($cvdInfo); $txnXMLString .= $mpgCvdInfo->toXML(); }
$custInfo = $txnObj->getCustInfo(); if($custInfo != null) { $txnXMLString .= $custInfo->toXML(); }
$txnXMLString .="</$txnType>";
$xmlString =$txnXMLString; return $xmlString;
}//end toXML
}//end class
##################### mpgCustInfo #######################################################
class mpgCustInfo{
var $level3template = array('cust_info'=>
array('email','instructions', 'billing' => array ('first_name', 'last_name', 'company_name', 'address', 'city', 'province', 'postal_code', 'country', 'phone_number', 'fax','tax1', 'tax2','tax3', 'shipping_cost'), 'shipping' => array('first_name', 'last_name', 'company_name', 'address', 'city', 'province', 'postal_code', 'country', 'phone_number', 'fax','tax1', 'tax2', 'tax3', 'shipping_cost'), 'item' => array ('name', 'quantity', 'product_code', 'extended_amount') ) );
var $level3data; var $email; var $instructions;
function __construct($custinfo=0,$billing=0,$shipping=0,$items=0) { if($custinfo) { $this->setCustInfo($custinfo); } }
function setCustInfo($custinfo) { $this->level3data['cust_info']=array($custinfo); }
function setEmail($email){
$this->email=$email; $this->setCustInfo(array('email'=>$email,'instructions'=>$this->instructions)); }
function setInstructions($instructions){
$this->instructions=$instructions; $this->setCustinfo(array('email'=>$this->email,'instructions'=>$instructions)); }
function setShipping($shipping) { $this->level3data['shipping']=array($shipping); }
function setBilling($billing) { $this->level3data['billing']=array($billing); }
function setItems($items) { if(!isset($this->level3data['item'])) { $this->level3data['item']=array($items); } else { $index=count($this->level3data['item']); $this->level3data['item'][$index]=$items; } }
function toXML() { $xmlString=$this->toXML_low($this->level3template,"cust_info"); return $xmlString; }
function toXML_low($template,$txnType) { $xmlString = ''; for($x=0;$x<count($this->level3data[$txnType]);$x++) { if($x>0) { $xmlString .="</$txnType><$txnType>"; } $keys=array_keys($template); for($i=0; $i < count($keys);$i++) { $tag=$keys[$i];
if(is_array($template[$keys[$i]])) { $data=$template[$tag];
if(! count($this->level3data[$tag])) { continue; } $beginTag="<$tag>"; $endTag="</$tag>";
$xmlString .=$beginTag; if(is_array($data)) { $returnString=$this->toXML_low($data,$tag); $xmlString .= $returnString; } $xmlString .=$endTag; } else { $tag=$template[$keys[$i]]; $beginTag="<$tag>"; $endTag="</$tag>"; $data=$this->level3data[$txnType][$x][$tag];
$xmlString .=$beginTag.$data.$endTag; }
}//end inner for
}//end outer for
return $xmlString; }//end toXML_low
#########################################mpgRecur################################################
class mpgRecur{
var $params; var $recurTemplate = array('recur_unit','start_now','start_date','num_recurs','period','recur_amount');
function __construct($params) { $this->params = $params;
if( (! $this->params['period']) ) { $this->params['period'] = 1; } }
function toXML() { foreach($this->recurTemplate as $tag) { $xmlString .= "<$tag>". $this->params[$tag] ."</$tag>"; }
return "<recur>$xmlString</recur>"; }
##################### mpgTransaction #######################################################
class mpgTransaction{
var $txn; var $custInfo = null; var $avsInfo = null; var $cvdInfo = null; var $recur = null;
$this->txn=$txn;
function getCustInfo(){ return $this->custInfo;}function setCustInfo($custInfo){ $this->custInfo = $custInfo; array_push($this->txn,$custInfo);}
function getCvdInfo(){ return $this->cvdInfo;}function setCvdInfo($cvdInfo){ $this->cvdInfo = $cvdInfo;}
function getAvsInfo(){ return $this->avsInfo;}function setAvsInfo($avsInfo){ $this->avsInfo = $avsInfo;}
function getRecur(){ return $this->recur;}function setRecur($recur){ $this->recur = $recur;}
function getTransaction(){
return $this->txn;}
##################### mpgAvsInfo #######################################################
class mpgAvsInfo{
var $params; var $avsTemplate = array('avs_street_number','avs_street_name','avs_zipcode');
function __construct($params) { $this->params = $params; }
function toXML() { $xmlString = ''; foreach($this->avsTemplate as $tag) { if(array_key_exists($tag, $this->params->params)) { $xmlString .= "<$tag>". $this->params->params[$tag] ."</$tag>"; } //$xmlString .= "<$tag>". $this->params[$tag] ."</$tag>"; } //echo $xmlString;die(); return "<avs_info>$xmlString</avs_info>"; }
##################### mpgCvdInfo #######################################################
class mpgCvdInfo{
var $params; var $cvdTemplate = array('cvd_indicator','cvd_value');
function toXML() { $xmlString = ''; foreach($this->cvdTemplate as $tag) { if(array_key_exists($tag, $this->params->params)) { $xmlString .= "<$tag>". $this->params->params[$tag] ."</$tag>"; } //$xmlString .= "<$tag>". $this->params[$tag] ."</$tag>"; }
return "<cvd_info>$xmlString</cvd_info>"; }
?>