Mutiple classes in one file from 3rd party.

I have an API file that defines many helper classes and objects in one file… I have been reading and it seems I can’t include these properly in Yii. This seems wrong. Here is the example file. Its for a very large payment processor in canada.

Do I really need to create a file for each class?

Example: (edited length of posted code)

<?php

#################### mpgGlobals ###########################################

class mpgGlobals

{

var &#036;Globals=array(


    	        MONERIS_PROTOCOL =&gt; 'https',


    	        MONERIS_HOST =&gt; 'esqa.moneris.com',


    	        MONERIS_PORT =&gt;'443',


           	  	MONERIS_FILE =&gt; '/gateway2/servlet/MpgRequest',


              	API_VERSION  =&gt;'PHP - 2.5.2 - Resolver',


              	CLIENT_TIMEOUT =&gt; '60'


             	);





function mpgGlobals()


{


	// default


}








function getGlobals()


{


	return(&#036;this-&gt;Globals);


}

}//end class mpgGlobals

###################### mpgHttpsPost #########################################

class mpgHttpsPost

{

var &#036;api_token;


var &#036;store_id;


var &#036;mpgRequest;


var &#036;mpgResponse;





function mpgHttpsPost(&#036;storeid,&#036;apitoken,&#036;mpgRequestOBJ)


{





	&#036;this-&gt;store_id=&#036;storeid;


	&#036;this-&gt;api_token= &#036;apitoken;


	&#036;this-&gt;mpgRequest=&#036;mpgRequestOBJ;


	&#036;dataToSend=&#036;this-&gt;toXML();





	//print(&quot;String to be sent = &quot; . &#036;dataToSend);





	//do post





	&#036;g=new mpgGlobals();


	&#036;gArray=&#036;g-&gt;getGlobals();


	&#036;transactionType=&#036;mpgRequestOBJ-&gt;getTransactionType();





	&#036;url =  &#036;gArray[MONERIS_PROTOCOL].&quot;://&quot;.


   			&#036;gArray[MONERIS_HOST].&quot;:&quot;.


  			&#036;gArray[MONERIS_PORT].


   			&#036;gArray[MONERIS_FILE];





	&#036;ch = curl_init();


	curl_setopt(&#036;ch, CURLOPT_URL,&#036;url);


	curl_setopt(&#036;ch, CURLOPT_RETURNTRANSFER,1);


	curl_setopt (&#036;ch, CURLOPT_HEADER, 0);


	curl_setopt(&#036;ch, CURLOPT_POST, 1);


	curl_setopt(&#036;ch, CURLOPT_POSTFIELDS,&#036;dataToSend);


	curl_setopt(&#036;ch,CURLOPT_TIMEOUT,&#036;gArray[CLIENT_TIMEOUT]);


	curl_setopt(&#036;ch,CURLOPT_USERAGENT,&#036;gArray[API_VERSION]);


	curl_setopt(&#036;ch, CURLOPT_SSL_VERIFYPEER, TRUE);





	&#036;response=curl_exec (&#036;ch);





	echo &quot;&#092;n&#092;nRESPONSE = &#036;response&quot;;





	curl_close (&#036;ch);





	if(&#33;&#036;response)


	{





 			&#036;response=&quot;&lt;?xml version=&#092;&quot;1.0&#092;&quot;?&gt;&lt;response&gt;&lt;receipt&gt;&quot;.


      			&quot;&lt;ReceiptId&gt;Global Error Receipt&lt;/ReceiptId&gt;&quot;.


      			&quot;&lt;ReferenceNum&gt;null&lt;/ReferenceNum&gt;&lt;ResponseCode&gt;null&lt;/ResponseCode&gt;&quot;.


      			&quot;&lt;AuthCode&gt;null&lt;/AuthCode&gt;&lt;TransTime&gt;null&lt;/TransTime&gt;&quot;.


      			&quot;&lt;TransDate&gt;null&lt;/TransDate&gt;&lt;TransType&gt;null&lt;/TransType&gt;&lt;Complete&gt;false&lt;/Complete&gt;&quot;.


      			&quot;&lt;Message&gt;Global Error Receipt&lt;/Message&gt;&lt;TransAmount&gt;null&lt;/TransAmount&gt;&quot;.


      			&quot;&lt;CardType&gt;null&lt;/CardType&gt;&quot;.


      			&quot;&lt;TransID&gt;null&lt;/TransID&gt;&lt;TimedOut&gt;null&lt;/TimedOut&gt;&quot;.


      			&quot;&lt;CorporateCard&gt;false&lt;/CorporateCard&gt;&lt;MessageId&gt;null&lt;/MessageId&gt;&quot;.


      			&quot;&lt;/receipt&gt;&lt;/response&gt;&quot;;


	}





	&#036;this-&gt;mpgResponse=new mpgResponse(&#036;response);





}











function getMpgResponse()


{


	return &#036;this-&gt;mpgResponse;





}





function toXML( )


{





	&#036;req=&#036;this-&gt;mpgRequest ;


	&#036;reqXMLString=&#036;req-&gt;toXML();





	&#036;xmlString .= &quot;&lt;?xml version=&#092;&quot;1.0&#092;&quot; encoding=&#092;&quot;iso-8859-1&#092;&quot;?&gt;&quot;.


           			&quot;&lt;request&gt;&quot;.


           			&quot;&lt;store_id&gt;&#036;this-&gt;store_id&lt;/store_id&gt;&quot;.


           			&quot;&lt;api_token&gt;&#036;this-&gt;api_token&lt;/api_token&gt;&quot;.


            		&#036;reqXMLString.


            		&quot;&lt;/request&gt;&quot;;





	return (&#036;xmlString);





}

}//end class mpgHttpsPost

###################### mpgHttpsPostStatus #########################################

class mpgHttpsPostStatus

{

var &#036;api_token;


var &#036;store_id;


var &#036;status;


var &#036;mpgRequest;


var &#036;mpgResponse;





function mpgHttpsPost(&#036;storeid,&#036;apitoken,&#036;status,&#036;mpgRequestOBJ, &#036;curlOptions = null)


{





	&#036;this-&gt;store_id=&#036;storeid;


	&#036;this-&gt;api_token= &#036;apitoken;


	&#036;this-&gt;status=&#036;status;


	&#036;this-&gt;mpgRequest=&#036;mpgRequestOBJ;


	&#036;dataToSend=&#036;this-&gt;toXML();





	//print(&quot;String to be sent = &quot; . &#036;dataToSend);





	//do post





	&#036;g=new mpgGlobals();


	&#036;gArray=&#036;g-&gt;getGlobals();


	&#036;transactionType=&#036;mpgRequestOBJ-&gt;getTransactionType();


	


	if(&#036;curlOptions &#33;= null &amp; is_array(&#036;curlOptions)){


	&#036;url =  &#036;curlOptions[&quot;protocol&quot;].&quot;://&quot;.


   			&#036;curlOptions[&quot;host&quot;].&quot;:&quot;.


  			&#036;curlOptions[&quot;port&quot;].


   			&#036;curlOptions[&quot;moneris_file&quot;];


	}


	else{


		&#036;url =  &#036;gArray[MONERIS_PROTOCOL].&quot;://&quot;.


				&#036;gArray[MONERIS_HOST].&quot;:&quot;.


				&#036;gArray[MONERIS_PORT].


				&#036;gArray[MONERIS_FILE];


	}


	&#036;ch = curl_init();


	curl_setopt(&#036;ch, CURLOPT_URL,&#036;url);


	curl_setopt(&#036;ch, CURLOPT_RETURNTRANSFER,1);


	curl_setopt (&#036;ch, CURLOPT_HEADER, 0);


	curl_setopt(&#036;ch, CURLOPT_POST, 1);


	curl_setopt(&#036;ch, CURLOPT_POSTFIELDS,&#036;dataToSend);


	curl_setopt(&#036;ch,CURLOPT_TIMEOUT,&#036;gArray[CLIENT_TIMEOUT]);


	curl_setopt(&#036;ch,CURLOPT_USERAGENT,&#036;gArray[API_VERSION]);


	curl_setopt(&#036;ch, CURLOPT_SSL_VERIFYPEER, TRUE);





	&#036;response=curl_exec (&#036;ch);





	echo &quot;&#092;n&#092;nRESPONSE = &#036;response&quot;;





	curl_close (&#036;ch);





	if(&#33;&#036;response)


	{





 			&#036;response=&quot;&lt;?xml version=&#092;&quot;1.0&#092;&quot;?&gt;&lt;response&gt;&lt;receipt&gt;&quot;.


      			&quot;&lt;ReceiptId&gt;Global Error Receipt&lt;/ReceiptId&gt;&quot;.


      			&quot;&lt;ReferenceNum&gt;null&lt;/ReferenceNum&gt;&lt;ResponseCode&gt;null&lt;/ResponseCode&gt;&quot;.


      			&quot;&lt;AuthCode&gt;null&lt;/AuthCode&gt;&lt;TransTime&gt;null&lt;/TransTime&gt;&quot;.


      			&quot;&lt;TransDate&gt;null&lt;/TransDate&gt;&lt;TransType&gt;null&lt;/TransType&gt;&lt;Complete&gt;false&lt;/Complete&gt;&quot;.


      			&quot;&lt;Message&gt;Global Error Receipt&lt;/Message&gt;&lt;TransAmount&gt;null&lt;/TransAmount&gt;&quot;.


      			&quot;&lt;CardType&gt;null&lt;/CardType&gt;&quot;.


      			&quot;&lt;TransID&gt;null&lt;/TransID&gt;&lt;TimedOut&gt;null&lt;/TimedOut&gt;&quot;.


      			&quot;&lt;CorporateCard&gt;false&lt;/CorporateCard&gt;&lt;MessageId&gt;null&lt;/MessageId&gt;&quot;.


      			&quot;&lt;/receipt&gt;&lt;/response&gt;&quot;;


	}





	&#036;this-&gt;mpgResponse=new mpgResponse(&#036;response);





}











function getMpgResponse()


{


	return &#036;this-&gt;mpgResponse;





}





function toXML( )


{





	&#036;req=&#036;this-&gt;mpgRequest ;


	&#036;reqXMLString=&#036;req-&gt;toXML();





	&#036;xmlString .= &quot;&lt;?xml version=&#092;&quot;1.0&#092;&quot; encoding=&#092;&quot;iso-8859-1&#092;&quot;?&gt;&quot;.


           			&quot;&lt;request&gt;&quot;.


           			&quot;&lt;store_id&gt;&#036;this-&gt;store_id&lt;/store_id&gt;&quot;.


           			&quot;&lt;api_token&gt;&#036;this-&gt;api_token&lt;/api_token&gt;&quot;.


           			&quot;&lt;status_check&gt;&#036;this-&gt;status&lt;/status_check&gt;&quot;.


            		&#036;reqXMLString.


            		&quot;&lt;/request&gt;&quot;;





	return (&#036;xmlString);





}

}//end class mpgHttpsPostStatus

############# mpgResponse #####################################################

class mpgResponse

{

var &#036;responseData;





var &#036;p; //parser





var &#036;currentTag;


var &#036;purchaseHash = array();


var &#036;refundHash;


var &#036;correctionHash = array();


var &#036;isBatchTotals;


var &#036;term_id;


var &#036;receiptHash = array();


var &#036;ecrHash = array();


var &#036;CardType;


var &#036;currentTxnType;


var &#036;ecrs = array();


var &#036;cards = array();


var &#036;cardHash= array();





//specifically for Resolver transactions


var &#036;resolveData;


var &#036;resolveDataHash;


var &#036;data_key=&quot;&quot;;


var &#036;DataKeys = array();





var &#036;ACSUrl;





function mpgResponse(&#036;xmlString)


{





	&#036;this-&gt;p = xml_parser_create();


	xml_parser_set_option(&#036;this-&gt;p,XML_OPTION_CASE_FOLDING,0);


	xml_parser_set_option(&#036;this-&gt;p,XML_OPTION_TARGET_ENCODING,&quot;UTF-8&quot;);


	xml_set_object(&#036;this-&gt;p,&#036;this);


	xml_set_element_handler(&#036;this-&gt;p,&quot;startHandler&quot;,&quot;endHandler&quot;);


	xml_set_character_data_handler(&#036;this-&gt;p,&quot;characterHandler&quot;);


	xml_parse(&#036;this-&gt;p,&#036;xmlString);


	xml_parser_free(&#036;this-&gt;p);





}	//end of constructor








function getMpgResponseData()


{


	return(&#036;this-&gt;responseData);


}





function getRecurSuccess()


{


	return (&#036;this-&gt;responseData['RecurSuccess']);


}





function getStatusCode()


{


 	return (&#036;this-&gt;responseData['status_code']);


}





function getStatusMessage()


{


 	return (&#036;this-&gt;responseData['status_message']);


}





function getAvsResultCode()


{


	return (&#036;this-&gt;responseData['AvsResultCode']);


}





function getCvdResultCode()


{


	return (&#036;this-&gt;responseData['CvdResultCode']);


}





function getCardType()


{


	return (&#036;this-&gt;responseData['CardType']);


}





function getTransAmount()


{


	return (&#036;this-&gt;responseData['TransAmount']);


}





function getTxnNumber()


{


	return (&#036;this-&gt;responseData['TransID']);


}





function getReceiptId()


{


	return (&#036;this-&gt;responseData['ReceiptId']);


}





function getTransType()


{


	return (&#036;this-&gt;responseData['TransType']);


}





function getReferenceNum()


{


	return (&#036;this-&gt;responseData['ReferenceNum']);


}





function getResponseCode()


{


	return (&#036;this-&gt;responseData['ResponseCode']);


}





function getISO()


{


	return (&#036;this-&gt;responseData['ISO']);


}





function getBankTotals()


{


	return (&#036;this-&gt;responseData['BankTotals']);


}





function getMessage()


{


	return (&#036;this-&gt;responseData['Message']);


}





function getAuthCode()


{


	return (&#036;this-&gt;responseData['AuthCode']);


}





function getComplete()


{


	return (&#036;this-&gt;responseData['Complete']);


}





function getTransDate()


{


	return (&#036;this-&gt;responseData['TransDate']);


}





function getTransTime()


{


	return (&#036;this-&gt;responseData['TransTime']);


}





function getTicket()


{


	return (&#036;this-&gt;responseData['Ticket']);


}





function getTimedOut()


{


	return (&#036;this-&gt;responseData['TimedOut']);


}





function getCorporateCard()


{


	return (&#036;this-&gt;responseData['CorporateCard']);


	}





	function getCavvResultCode()


	{


	return (&#036;this-&gt;responseData['CavvResultCode']);


}





function getCardLevelResult()


{


	return (&#036;this-&gt;responseData['CardLevelResult']);


}





function getITDResponse()


{


	return (&#036;this-&gt;responseData['ITDResponse']);


}





function getMpiType()


{


	return (&#036;this-&gt;responseData['MpiType']);


}





function getMpiSuccess()


{


	return (&#036;this-&gt;responseData['MpiSuccess']);


}





function getMpiMessage()


{


	return (&#036;this-&gt;responseData['MpiMessage']);


}





function getMpiPaReq()


{


	return (&#036;this-&gt;responseData['MpiPaReq']);


}





function getMpiTermUrl()


{


	return (&#036;this-&gt;responseData['MpiTermUrl']);


}





function getMpiMD()


{


	return (&#036;this-&gt;responseData['MpiMD']);


}





function getMpiACSUrl()


{


	return (&#036;this-&gt;responseData['MpiACSUrl']);


}





function getMpiCavv()


{


	return (&#036;this-&gt;responseData['MpiCavv']);


}





function getMpiPAResVerified()


{


	return (&#036;this-&gt;responseData['MpiPAResVerified']);


}





function getMpiInLineForm()


{


	


	&#036;inLineForm ='&lt;html&gt;&lt;head&gt;&lt;title&gt;Title for Page&lt;/title&gt;&lt;/head&gt;&#60;script LANGUAGE=&quot;Javascript&quot; &gt;' . 


			&quot;&#60;&#33;--


			function OnLoadEvent()


			{


			document.downloadForm.submit();


			}


			--&#62;


			&lt;/SCRIPT&gt;&quot; .


			'&lt;body onload=&quot;OnLoadEvent()&quot;&gt;


			&lt;form name=&quot;downloadForm&quot; action=&quot;' . &#036;this-&gt;getMpiACSUrl() . 


			'&quot; method=&quot;POST&quot;&gt;


			&lt;noscript&gt;


			&lt;br&gt;


			&lt;br&gt;


			&lt;center&gt;


			&lt;h1&gt;Processing your 3-D Secure Transaction&lt;/h1&gt;


			&lt;h2&gt;


			JavaScript is currently disabled or is not supported


			by your browser.&lt;br&gt;


			&lt;h3&gt;Please click on the Submit button to continue


			the processing of your 3-D secure


			transaction.&lt;/h3&gt;


			&lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;


			&lt;/center&gt;


			&lt;/noscript&gt;


			&lt;input type=&quot;hidden&quot; name=&quot;PaReq&quot; value=&quot;' . &#036;this-&gt;getMpiPaReq() . '&quot;&gt;


			&lt;input type=&quot;hidden&quot; name=&quot;MD&quot; value=&quot;' . &#036;this-&gt;getMpiMD() . '&quot;&gt;


			&lt;input type=&quot;hidden&quot; name=&quot;TermUrl&quot; value=&quot;' . &#036;this-&gt;getMpiTermUrl() .'&quot;&gt;


			&lt;/form&gt;


			&lt;/body&gt;


			&lt;/html&gt;';





	return &#036;inLineForm; 


}








//--------------------------- RecurUpdate response fields ----------------------------//





function getRecurUpdateSuccess()


{


	return (&#036;this-&gt;responseData['RecurUpdateSuccess']);


}





function getNextRecurDate()


{


	return (&#036;this-&gt;responseData['NextRecurDate']);


}





function getRecurEndDate()


{


	return (&#036;this-&gt;responseData['RecurEndDate']);


}





//-------------------------- Resolver response fields --------------------------------//





function getDataKey()


{


	return (&#036;this-&gt;responseData['DataKey']);


}





function getResSuccess()


{


	return (&#036;this-&gt;responseData['ResSuccess']);


}





function getPaymentType()


{


	return (&#036;this-&gt;responseData['PaymentType']);


}





//------------------------------------------------------------------------------------//





function getResolveData()


{


	if(&#036;this-&gt;responseData['ResolveData']&#33;='null'){


		return (&#036;this-&gt;resolveData);


	}





	return &#036;this-&gt;responseData['ResolveData'];


}





function setResolveData(&#036;data_key)


{


	&#036;this-&gt;resolveData=&#036;this-&gt;resolveDataHash[&#036;data_key];


}





function getResolveDataHash()


{


	return (&#036;this-&gt;resolveDataHash);


}





function getDataKeys()


{


 	return (&#036;this-&gt;DataKeys);


}





function getResDataDataKey()


{


	return (&#036;this-&gt;resolveData['data_key']);


}





function getResDataPaymentType()


{


	return (&#036;this-&gt;resolveData['payment_type']);


}





function getResDataCustId()


{


	return (&#036;this-&gt;resolveData['cust_id']);


}





function getResDataPhone()


{


	return (&#036;this-&gt;resolveData['phone']);


}





function getResDataEmail()


{


	return (&#036;this-&gt;resolveData['email']);


}





function getResDataNote()


{


	return (&#036;this-&gt;resolveData['note']);


}





function getResDataPan()


{


	return (&#036;this-&gt;resolveData['pan']);


}





function getResDataMaskedPan()


{


	return (&#036;this-&gt;resolveData['masked_pan']);


}





function getResDataExpDate()


{


	return (&#036;this-&gt;resolveData['expdate']);


}





function getResDataAvsStreetNumber()


{


	return (&#036;this-&gt;resolveData['avs_street_number']);


}





function getResDataAvsStreetName()


{


	return (&#036;this-&gt;resolveData['avs_street_name']);


}





function getResDataAvsZipcode()


{


	return (&#036;this-&gt;resolveData['avs_zipcode']);


}





function getResDataCryptType()


{


	return (&#036;this-&gt;resolveData['crypt_type']);


}











//--------------------------- BatchClose response fields -----------------------------//





function getTerminalStatus(&#036;ecr_no)


{


	return (&#036;this-&gt;ecrHash[&#036;ecr_no]);


}





function getPurchaseAmount(&#036;ecr_no,&#036;card_type)


{


	return (&#036;this-&gt;purchaseHash[&#036;ecr_no][&#036;card_type]['Amount']==&quot;&quot; ? 0:&#036;this-&gt;purchaseHash[&#036;ecr_no][&#036;card_type]['Amount']);


}





function getPurchaseCount(&#036;ecr_no,&#036;card_type)


{


	return (&#036;this-&gt;purchaseHash[&#036;ecr_no][&#036;card_type]['Count']==&quot;&quot; ? 0:&#036;this-&gt;purchaseHash[&#036;ecr_no][&#036;card_type]['Count']);


}





function getRefundAmount(&#036;ecr_no,&#036;card_type)


{


	return (&#036;this-&gt;refundHash[&#036;ecr_no][&#036;card_type]['Amount']==&quot;&quot; ? 0:&#036;this-&gt;refundHash[&#036;ecr_no][&#036;card_type]['Amount']);


}





function getRefundCount(&#036;ecr_no,&#036;card_type)


{


	return (&#036;this-&gt;refundHash[&#036;ecr_no][&#036;card_type]['Count']==&quot;&quot; ? 0:&#036;this-&gt;refundHash[&#036;ecr_no][&#036;card_type]['Count']);


}





function getCorrectionAmount(&#036;ecr_no,&#036;card_type)


{


	return (&#036;this-&gt;correctionHash[&#036;ecr_no][&#036;card_type]['Amount']==&quot;&quot; ? 0:&#036;this-&gt;correctionHash[&#036;ecr_no][&#036;card_type]['Amount']);


}





function getCorrectionCount(&#036;ecr_no,&#036;card_type)


{


	return (&#036;this-&gt;correctionHash[&#036;ecr_no][&#036;card_type]['Count']==&quot;&quot; ? 0:&#036;this-&gt;correctionHash[&#036;ecr_no][&#036;card_type]['Count']);


}





function getTerminalIDs()


{


	return (&#036;this-&gt;ecrs);


}





function getCreditCardsAll()


{


	return (array_keys(&#036;this-&gt;cards));


}





function getCreditCards(&#036;ecr)


{


	return (&#036;this-&gt;cardHash[&#036;ecr]);


}











function characterHandler(&#036;parser,&#036;data)


{


	if(&#036;this-&gt;isBatchTotals)


	{


		switch(&#036;this-&gt;currentTag)


		{


 			case &quot;term_id&quot;    :


			{


				&#036;this-&gt;term_id=&#036;data;


				array_push(&#036;this-&gt;ecrs,&#036;this-&gt;term_id);


				&#036;this-&gt;cardHash[&#036;data]=array();


				break;


			}





 			case &quot;closed&quot;     :


			{


				&#036;ecrHash=&#036;this-&gt;ecrHash;


				&#036;ecrHash[&#036;this-&gt;term_id]=&#036;data;


				&#036;this-&gt;ecrHash = &#036;ecrHash;


				break;


			}





 			case &quot;CardType&quot;   :


			{


				&#036;this-&gt;CardType=&#036;data;


				&#036;this-&gt;cards[&#036;data]=&#036;data;


				array_push(&#036;this-&gt;cardHash[&#036;this-&gt;term_id],&#036;data) ;


				break;


			}





 			case &quot;Amount&quot;     :


			{


				if(&#036;this-&gt;currentTxnType == &quot;Purchase&quot;)


				{


					&#036;this-&gt;purchaseHash[&#036;this-&gt;term_id][&#036;this-&gt;CardType]['Amount']=&#036;data;


				}


				elseif( &#036;this-&gt;currentTxnType == &quot;Refund&quot;)


				{


					&#036;this-&gt;refundHash[&#036;this-&gt;term_id][&#036;this-&gt;CardType]['Amount']=&#036;data;


				}


				elseif( &#036;this-&gt;currentTxnType == &quot;Correction&quot;)


				{


					&#036;this-&gt;correctionHash[&#036;this-&gt;term_id][&#036;this-&gt;CardType]['Amount']=&#036;data;


				}


				break;


			 }





			case &quot;Count&quot;     :


			{


				if(&#036;this-&gt;currentTxnType == &quot;Purchase&quot;)


				{


					&#036;this-&gt;purchaseHash[&#036;this-&gt;term_id][&#036;this-&gt;CardType]['Count']=&#036;data;


				}


				elseif( &#036;this-&gt;currentTxnType == &quot;Refund&quot;)


				{


					&#036;this-&gt;refundHash[&#036;this-&gt;term_id][&#036;this-&gt;CardType]['Count']=&#036;data;


				}


				else if( &#036;this-&gt;currentTxnType == &quot;Correction&quot;)


				{


					&#036;this-&gt;correctionHash[&#036;this-&gt;term_id][&#036;this-&gt;CardType]['Count']=&#036;data;


				}


				break;


			}


    	}





	}


	elseif(&#036;this-&gt;isResolveData &amp;&amp; &#036;this-&gt;currentTag &#33;= &quot;ResolveData&quot;)


	{


		if(&#036;this-&gt;currentTag == &quot;data_key&quot;)


		{


			&#036;this-&gt;data_key=&#036;data;


			array_push(&#036;this-&gt;DataKeys,&#036;this-&gt;data_key);


			&#036;this-&gt;resolveData[&#036;this-&gt;currentTag] .=&#036;data;


		}


		else


		{


			&#036;this-&gt;resolveData[&#036;this-&gt;currentTag] .=&#036;data;


		}


	}


	else


	{


		&#036;this-&gt;responseData[&#036;this-&gt;currentTag] .=&#036;data;


	}





}//end characterHandler











function startHandler(&#036;parser,&#036;name,&#036;attrs)


{





	&#036;this-&gt;currentTag=&#036;name;





	if(&#036;this-&gt;currentTag == &quot;ResolveData&quot;)


	{


		&#036;this-&gt;isResolveData=1;


 	}


 	elseif(&#036;this-&gt;isResolveData)


 	{


 		&#036;this-&gt;resolveData[&#036;this-&gt;currentTag]=&quot;&quot;;


 	}





	if(&#036;this-&gt;currentTag == &quot;BankTotals&quot;)


 	{


  		&#036;this-&gt;isBatchTotals=1;


 	}


	elseif(&#036;this-&gt;currentTag == &quot;Purchase&quot;)


	{


 		&#036;this-&gt;purchaseHash[&#036;this-&gt;term_id][&#036;this-&gt;CardType]=array();


 		&#036;this-&gt;currentTxnType=&quot;Purchase&quot;;


	}


	elseif(&#036;this-&gt;currentTag == &quot;Refund&quot;)


 	{


  		&#036;this-&gt;refundHash[&#036;this-&gt;term_id][&#036;this-&gt;CardType]=array();


  		&#036;this-&gt;currentTxnType=&quot;Refund&quot;;


 	}


	elseif(&#036;this-&gt;currentTag == &quot;Correction&quot;)


	{


 		&#036;this-&gt;correctionHash[&#036;this-&gt;term_id][&#036;this-&gt;CardType]=array();


 		&#036;this-&gt;currentTxnType=&quot;Correction&quot;;


	}


}





function endHandler(&#036;parser,&#036;name)


{





 	&#036;this-&gt;currentTag=&#036;name;


 	if(&#036;this-&gt;currentTag == &quot;ResolveData&quot;)


	{


		&#036;this-&gt;isResolveData=0;


		if(&#036;this-&gt;data_key&#33;=&quot;&quot;)


		{


			&#036;this-&gt;resolveDataHash[&#036;this-&gt;data_key]=&#036;this-&gt;resolveData;


			&#036;this-&gt;resolveData=array();


		}


 	}


 	if(&#036;name == &quot;BankTotals&quot;)


  	{


    	&#036;this-&gt;isBatchTotals=0;


   	}





	&#036;this-&gt;currentTag=&quot;/dev/null&quot;;


}

}//end class mpgResponse

################## mpgRequest ###########################################################

class mpgRequest

{

var &#036;txnTypes =array(


		purchase=&gt; array('order_id','cust_id', 'amount', 'pan', 'expdate', 'crypt_type','dynamic_descriptor'),


	    	refund =&gt; array('order_id', 'amount', 'txn_number', 'crypt_type'),


	    	idebit_purchase =&gt;array('order_id', 'cust_id', 'amount','idebit_track2','dynamic_descriptor'),


	    	idebit_refund =&gt;array('order_id','amount','txn_number'),


	    	ind_refund =&gt; array('order_id','cust_id', 'amount','pan','expdate', 'crypt_type','dynamic_descriptor'),


	    	preauth =&gt;array('order_id','cust_id', 'amount', 'pan', 'expdate', 'crypt_type','dynamic_descriptor'),


	    	reauth =&gt;array('order_id','cust_id', 'amount', 'orig_order_id', 'txn_number', 'crypt_type'),


	    	completion =&gt; array('order_id', 'comp_amount','txn_number', 'crypt_type'),


	    	purchasecorrection =&gt; array('order_id', 'txn_number', 'crypt_type'),


	    	opentotals =&gt; array('ecr_number'),


	    	batchclose =&gt; array('ecr_number'),


	    	card_verification =&gt;array('order_id','cust_id','pan','expdate'),


	    	cavv_purchase=&gt; array('order_id','cust_id', 'amount', 'pan','expdate', 'cavv','dynamic_descriptor'),


		cavv_preauth =&gt;array('order_id','cust_id', 'amount', 'pan','expdate', 'cavv','dynamic_descriptor'),


		recur_update =&gt; array('order_id','cust_id','pan','expdate','recur_amount','add_num_recurs','total_num_recurs','hold','terminate'),


		res_add_cc =&gt; array('cust_id','phone','email','note','pan','expdate','crypt_type'),


		res_add_token =&gt; array('data_key','cust_id','phone','email','note','expdate','crypt_type'),


		res_temp_add =&gt; array('pan','expdate','crypt_type','duration'),


		res_tokenize_cc =&gt; array('order_id','txn_number','cust_id','phone','email','note'),


		res_update_cc =&gt; array('data_key','cust_id','phone','email','note','pan','expdate','crypt_type'),


		res_delete =&gt; array('data_key'),


		res_lookup_full =&gt; array('data_key'),


		res_lookup_masked =&gt; array('data_key'),


		res_get_expiring =&gt; array(),


		res_purchase_cc =&gt; array('data_key','order_id','cust_id','amount','crypt_type','dynamic_descriptor','expdate'),


		res_preauth_cc =&gt; array('data_key','order_id','cust_id','amount','crypt_type','dynamic_descriptor','expdate'),


		res_ind_refund_cc =&gt; array('data_key','order_id','cust_id','amount','crypt_type','dynamic_descriptor'),


		res_iscorporatecard =&gt; array('data_key'),


		res_mpitxn =&gt; array('data_key','xid','amount','MD','merchantUrl','accept','userAgent'),


		res_cavv_purchase_cc =&gt; array('data_key','order_id','cust_id','amount','cavv','dynamic_descriptor'),


		res_cavv_preauth_cc =&gt; array('data_key','order_id','cust_id','amount','cavv','dynamic_descriptor')


		);





var &#036;txnArray;





function mpgRequest(&#036;txn)


{





	if(is_array(&#036;txn))


	{


			&#036;this-&gt;txnArray = &#036;txn;


	}


	else


	{


			&#036;temp[0]=&#036;txn;


			&#036;this-&gt;txnArray=&#036;temp;


	}


}





function getTransactionType()


{


	&#036;jtmp=&#036;this-&gt;txnArray;


	&#036;jtmp1=&#036;jtmp[0]-&gt;getTransaction();


	&#036;jtmp2=array_shift(&#036;jtmp1);


	return &#036;jtmp2;


}





function toXML()


{





	&#036;tmpTxnArray=&#036;this-&gt;txnArray;


	&#036;txnArrayLen=count(&#036;tmpTxnArray); //total number of transactions





	for(&#036;x=0;&#036;x &lt; &#036;txnArrayLen;&#036;x++)


	{


		&#036;txnObj=&#036;tmpTxnArray[&#036;x];


		&#036;txn=&#036;txnObj-&gt;getTransaction();





		&#036;txnType=array_shift(&#036;txn);


		&#036;tmpTxnTypes=&#036;this-&gt;txnTypes;


		&#036;txnTypeArray=&#036;tmpTxnTypes[&#036;txnType];


		&#036;txnTypeArrayLen=count(&#036;txnTypeArray); //length of a specific txn type





		&#036;txnXMLString=&quot;&quot;;





		for(&#036;i=0;&#036;i &lt; &#036;txnTypeArrayLen ;&#036;i++)


		{


			//Will only add to the XML if the tag was passed in by merchant


			if(array_key_exists(&#036;txnTypeArray[&#036;i], &#036;txn))


            {


			 	&#036;txnXMLString  .=&quot;&lt;&#036;txnTypeArray[&#036;i]&gt;&quot;   //begin tag


								.&#036;txn[&#036;txnTypeArray[&#036;i]] // data


								. &quot;&lt;/&#036;txnTypeArray[&#036;i]&gt;&quot;; //end tag


			}


		}





		&#036;txnXMLString = &quot;&lt;&#036;txnType&gt;&#036;txnXMLString&quot;;








		&#036;recur  = &#036;txnObj-&gt;getRecur();


		if(&#036;recur &#33;= null)


		{


     			&#036;txnXMLString .= &#036;recur-&gt;toXML();


		}





		&#036;avs  = &#036;txnObj-&gt;getAvsInfo();


		if(&#036;avs &#33;= null)


		{


			&#036;txnXMLString .= &#036;avs-&gt;toXML();


		}





		&#036;cvd  = &#036;txnObj-&gt;getCvdInfo();


		if(&#036;cvd &#33;= null)


		{


			&#036;txnXMLString .= &#036;cvd-&gt;toXML();


		}





		&#036;custInfo = &#036;txnObj-&gt;getCustInfo();


		if(&#036;custInfo &#33;= null)


		{


    		&#036;txnXMLString .= &#036;custInfo-&gt;toXML();


		}





		&#036;txnXMLString .=&quot;&lt;/&#036;txnType&gt;&quot;;


		&#036;xmlString .=&#036;txnXMLString;





	}





	return &#036;xmlString;





}//end toXML

}//end class

Double post sorry!

Sorry, but please don’t bother us with the lengthy code. No one will read it.

I think you can just include the file in "index.php".

i think You have to put all your classes under one namespace.

@Yii3

All those classes in the library are under the global namespace.

I don’t think we need to place them in a specific namespace, unless you need to use other classes with the same names. All the classes in the library seems to be named with a common prefix of “mpg” in order to avoid a name collision, so probably we will be safe to use them as they are.

The same thing goes with the famous PHPExcel library that is one of my favorites. I’m using it with Yii 2.0 without any problem. The classes of the library are not namespaced, but have a common prefix of “PHPExcel_”.

One of the drawbacks of "multiple classes in a single file" might be a fact that you may not be able to autoload the classes in the library. You may have to "include" or "require" the file explicitly. But that should not be a big problem in this case.

Thanks for the quick reply. I will refrain from posting large code snippets.

I included the file in the index.php in the frontend\web folder.

I get an error that

Class ‘common\models\mpgTransaction’ not found when I use

$mpgTxn = new mpgTransaction($txnArray);

What should I put at the top of the file that is using these classes?

Hey so I was able to get Yii to recognize the class by putting a preceding forward slash like below. I read that in some artivcle last night and guessed.

$mpgTxn = new \mpgTransaction($txnArray);

What does the slash do?

It indicates the root of the namespace.

Without it, names are considered to belong to the current namespace like "common\models".

Thanks so much. This will be very very helpful in the future.