<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Joomla VIKrentcar integration in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Joomla-VIKrentcar-integration/m-p/36847#M20459</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to integrate my authorize.net account with my joomla component, which has an already built in authorize.net payment gateway.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using https&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code I have from them, and with whom my transactions get denied:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;?php
/**
 * Copyright (c) Extensionsforjoomla.com - E4J - Alessio &amp;lt;tech@extensionsforjoomla.com&amp;gt;
 * 
 * You should have received a copy of the License
 * along with this program.  If not, see &amp;lt;&lt;A href="https://community.developer.cybersource.com/" target="_blank"&gt;http://www.extensionsforjoomla.com/&amp;gt;.&lt;/A&gt;
 * 
 * For any bug, error please contact &amp;lt;tech@extensionsforjoomla.com&amp;gt;
 * We will try to fix it.
 * 
 * Extensionsforjoomla.com - All Rights Reserved
 * 
 */

defined('_JEXEC') OR die('Restricted Area');
error_reporting(0);

class vikRentCarPayment {
	
	private $order_info;
	
	private $login = "1234567thisisok"; //Put you Authorize.net Login ID here
	private $transkey = "12345678910thisisok"; //Put you Authorize.net Transaction Key here
	private $url = "&lt;A href="https://secure.authorize.net/gateway/transact.dll&amp;quot;;" target="_blank"&gt;https://secure.authorize.net/gateway/transact.dll";&lt;/A&gt; //If not testing, use &lt;A href="https://secure.authorize.net/gateway/transact.dll" target="_blank"&gt;https://secure.authorize.net/gateway/transact.dll&lt;/A&gt;
	
	private $params = array();
	private $results = array();
	
	private $approved = false;
	private $declined = false;
	private $error = true;
	
	private $fields;
	private $response;
	
	static $instances = 0;
	
	public function __construct ($order) {
		if (self::$instances == 0) {
			self::$instances++;
			$this-&amp;gt;order_info = $order;
			$this-&amp;gt;params['x_delim_data'] = "TRUE";
			$this-&amp;gt;params['x_delim_char'] = "|";
			$this-&amp;gt;params['x_relay_response'] = "FALSE";
			$this-&amp;gt;params['x_url'] = "FALSE";
			$this-&amp;gt;params['x_version'] = "3.1";
			$this-&amp;gt;params['x_method'] = "CC";
			$this-&amp;gt;params['x_type'] = "AUTH_CAPTURE"; //Change to AUTH_ONLY for not charging the client, see authorize.net for more details
			$this-&amp;gt;params['x_login'] = $this-&amp;gt;login;
			$this-&amp;gt;params['x_tran_key'] = $this-&amp;gt;transkey;
		}else {
			return false;
		}
	}
	
	public function showPayment () {
		$depositmess="";
		$actionurl = $this-&amp;gt;order_info['notify_url'];
		//to enable ssl in the payment validation page decomment the line below
		$actionurl = str_replace('http:', 'https:', $actionurl);
		
		//to enable ssl in the credit card info page decomment the lines below
		if ($_SERVER['HTTPS'] != "on") {
			$url = $this-&amp;gt;order_info['return_url'];
			$mainframe =&amp;amp; JFactory::getApplication();
			$mainframe-&amp;gt;redirect(str_replace('http:', 'https:', $url));
			exit;
		}
		
		$form="&amp;lt;br clear=\"all\"/&amp;gt;&amp;lt;form action=\"".$actionurl."\" method=\"post\" name=\"authorizenetpaymform\"&amp;gt;\n";
		$form.="&amp;lt;table&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCCREDITCARDNUMBER').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"credit_card_number\" name=\"credit_card_number\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.='&amp;lt;tr&amp;gt;&amp;lt;td align="right"&amp;gt;'.JText::_('VRCCVALIDTHROUGH').': &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;select name="expire_month"&amp;gt;
				&amp;lt;option value="01"&amp;gt;January&amp;lt;/option&amp;gt;
				&amp;lt;option value="02"&amp;gt;February&amp;lt;/option&amp;gt;
				&amp;lt;option value="03"&amp;gt;March&amp;lt;/option&amp;gt;
				&amp;lt;option value="04"&amp;gt;April&amp;lt;/option&amp;gt;
				&amp;lt;option value="05"&amp;gt;May&amp;lt;/option&amp;gt;
				&amp;lt;option value="06"&amp;gt;June&amp;lt;/option&amp;gt;
				&amp;lt;option value="07"&amp;gt;July&amp;lt;/option&amp;gt;
				&amp;lt;option value="08"&amp;gt;August&amp;lt;/option&amp;gt;
				&amp;lt;option value="09"&amp;gt;September&amp;lt;/option&amp;gt;
				&amp;lt;option value="10"&amp;gt;October&amp;lt;/option&amp;gt;
				&amp;lt;option value="11"&amp;gt;November&amp;lt;/option&amp;gt;
				&amp;lt;option value="12"&amp;gt;December&amp;lt;/option&amp;gt;
				&amp;lt;/select&amp;gt; ';
		$maxyear = date("Y");
		$form.='&amp;lt;select name="expire_year"&amp;gt;';
		for ($i = $maxyear; $i &amp;lt;= ($maxyear + 10); $i++) {
			$form.='&amp;lt;option value="'.substr($i, -2, 2).'"&amp;gt;'.$i.'&amp;lt;/option&amp;gt;';
		}
		$form.='&amp;lt;/select&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'."\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCCVV').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"credit_card_cvv\" name=\"credit_card_cvv\" size=\"5\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCFIRSTNAME').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_first_name\" name=\"business_first_name\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCLASTNAME').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_last_name\" name=\"business_last_name\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"left\" colspan=\"2\"&amp;gt;&amp;lt;strong&amp;gt;".JText::_('VRCCBILLINGINFO').":&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCCOMPANY').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_company\" name=\"business_company\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCADDRESS').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_address\" name=\"business_address\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCCITY').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_city\" name=\"business_city\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCSTATEPROVINCE').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_state_province\" name=\"business_state_province\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCZIP').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_zipcode\" name=\"business_zipcode\" size=\"5\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCCOUNTRY').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_country\" name=\"business_country\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCPHONE').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_phone\" name=\"business_country\" size=\"15\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCEMAIL').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_email\" name=\"business_email\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\" colspan=\"2\"&amp;gt;&amp;lt;input type=\"submit\" id=\"authorizenetsubmit\" name=\"authorizenetsubmit\" class=\"button\" value=\"".JText::_('VRCCPROCESSPAY')."\" onclick=\"javascript&amp;amp;colon; event.preventDefault(); this.disabled = true; this.value = '".addslashes(JText::_('VRCCPROCESSING'))."'; document.authorizenetpaymform.submit(); return true;\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;/table&amp;gt;\n";
		$form.="&amp;lt;input type=\"hidden\" name=\"total\" value=\"".number_format(($this-&amp;gt;order_info['total_to_pay'] / 7.6), 2)."\"/&amp;gt;\n";
		$form.="&amp;lt;input type=\"hidden\" name=\"description\" value=\"".$this-&amp;gt;order_info['rooms_name']."\"/&amp;gt;\n";
		$form.="&amp;lt;/form&amp;gt;\n";
		
		if($this-&amp;gt;order_info['leave_deposit']) {
			$depositmess="&amp;lt;br/&amp;gt;&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;".JText::_('VRLEAVEDEPOSIT')." ".number_format($this-&amp;gt;order_info['total_to_pay'], 2)." ".$this-&amp;gt;order_info['currency_symb']."&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;br/&amp;gt;";
		}
		//output form
		echo $depositmess;
		echo $this-&amp;gt;order_info['payment_info']['note'];
		echo $form;
		
		return true;
	}
	
	public function validatePayment () {
		$log="";
		$array_result=array();
		$array_result['verified'] = 0;
		
		//post data
		$creditcard = JRequest :: getString('credit_card_number', '', 'request');
		$expire_month = JRequest :: getString('expire_month', '', 'request');
		$expire_year = JRequest :: getString('expire_year', '', 'request');
		$cvv = JRequest :: getString('credit_card_cvv', '', 'request');
		$total = JRequest :: getString('total', '', 'request');
		//billing information
		$business_first_name = JRequest :: getString('business_first_name', '', 'request');
		self::setParameter('x_first_name', $business_first_name);
		$business_last_name = JRequest :: getString('business_last_name', '', 'request');
		self::setParameter('x_last_name', $business_last_name);
		$business_company = JRequest :: getString('business_company', '', 'request');
		self::setParameter('x_company', $business_company);
		$business_address = JRequest :: getString('business_address', '', 'request');
		self::setParameter('x_address', $business_address);
		$business_city = JRequest :: getString('business_city', '', 'request');
		self::setParameter('x_city', $business_city);
		$business_state_province = JRequest :: getString('business_state_province', '', 'request');
		self::setParameter('x_state', $business_state_province);
		$business_zipcode = JRequest :: getString('business_zipcode', '', 'request');
		self::setParameter('x_zip', $business_zipcode);
		$business_country = JRequest :: getString('business_country', '', 'request');
		self::setParameter('x_country', $business_country);
		$business_phone = JRequest :: getString('business_phone', '', 'request');
		self::setParameter('x_phone', $business_phone);
		$business_email = JRequest :: getString('business_email', '', 'request');
		self::setParameter('x_email', $business_email);
		$description = JRequest :: getString('description', '', 'request');
		self::setParameter('x_description', $description);
		//end billing information
		//end post data
		
		//post data validation
		$error_redirect_url = 'index.php?option=com_vikrentcar&amp;amp;task=vieworder&amp;amp;sid='.$this-&amp;gt;order_info['sid'].'&amp;amp;ts='.$this-&amp;gt;order_info['ts'];
		$valid_data = true;
		$current_month = date("m");
		$current_year = date("y");
		if ((int)$expire_year &amp;lt; (int)$current_year) {
			$valid_data = false;
		} else { 
			if ((int)$expire_year == (int)$current_year) {
				if ((int)$expire_month &amp;lt; (int)$current_month) {
					$valid_data = false;
				}
			}
		}
		if(empty($creditcard)) {
			$valid_data = false;
		}
		if(!$valid_data) {
			JError::raiseWarning('', 'Invalid Data Received for processing the payment, please try again');
			$mainframe =&amp;amp; JFactory::getApplication();
			$mainframe-&amp;gt;redirect($error_redirect_url);
			exit;
		}
		//end post data validation
		
		self::transaction(trim($creditcard), $expire_month.$expire_year, $total, $cvv);
		self::process();
		
		$log = print_r($this-&amp;gt;results, true);
		$array_result['log'] = $log;
		
		if (self::isApproved()) {
			$array_result['verified'] = 1;
			$array_result['tot_paid']=self::getTotalAmountPaid();
		}elseif (self::isDeclined()) {
			$array_result['log'] .= "\nDeclined"; 
		}else {
			$array_result['log'] .= "\nError"; 
		}
		
		return $array_result;
	}
	
	//this function is called after the payment has been validated for redirect actions
	//When this method is called, the class is invoked at the same time as validatePayment()
	public function afterValidation ($esit = 0) {
		$redirect_url = 'index.php?option=com_vikrentcar&amp;amp;task=vieworder&amp;amp;sid='.$this-&amp;gt;order_info['sid'].'&amp;amp;ts='.$this-&amp;gt;order_info['ts'];
		
		if($esit &amp;lt; 1) {
			$responsetxt = self::getResponseText();
			JError::raiseWarning('', (strlen(trim($responsetxt)) &amp;gt; 0 ? $responsetxt.'&amp;lt;br/&amp;gt;' : '').'The payment was not verified, please try again');
		}else {
			$app =&amp;amp; JFactory::getApplication();
			$app-&amp;gt;enqueueMessage('Thank you! The payment was verified successfully');
		}
		
		$mainframe =&amp;amp; JFactory::getApplication();
		$mainframe-&amp;gt;redirect($redirect_url);
		exit;
		//
	}
	
	public function transaction($cardnum, $expiration, $amount, $cvv = "", $invoice = "", $tax = "") {
		$this-&amp;gt;params['x_card_num'] = trim($cardnum);
		$this-&amp;gt;params['x_exp_date'] = trim($expiration);
		$this-&amp;gt;params['x_amount'] = trim($amount);
		$this-&amp;gt;params['x_po_num'] = trim($invoice);
		$this-&amp;gt;params['x_tax'] = trim($tax);
		$this-&amp;gt;params['x_card_code'] = trim($cvv);
	}

	public function process($retries = 3) {
		$this-&amp;gt;_prepareParameters();
		$ch = curl_init($this-&amp;gt;url);
		$count = 0;
		while ($count &amp;lt; $retries) {
			curl_setopt($ch, CURLOPT_HEADER, 0);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim($this-&amp;gt;fields, "&amp;amp; "));
			$this-&amp;gt;response = curl_exec($ch);
			$this-&amp;gt;_parseResults();
			if ($this-&amp;gt;getResultResponseFull() == "Approved") {
				$this-&amp;gt;approved = true;
				$this-&amp;gt;declined = false;
				$this-&amp;gt;error = false;
				break;
			} elseif ($this-&amp;gt;getResultResponseFull() == "Declined") {
				$this-&amp;gt;approved = false;
				$this-&amp;gt;declined = true;
				$this-&amp;gt;error = false;
				break;
			}
			$count++;
		}
		curl_close($ch);
	}

	private function _parseResults() {
		$this-&amp;gt;results = explode("|", $this-&amp;gt;response);
	}

	public function setParameter($param, $value) {
		$param = trim($param);
		$value = trim($value);
		$this-&amp;gt;params[$param] = $value;
	}

	public function setTransactionType($type) {
		$this-&amp;gt;params['x_type'] = strtoupper(trim($type));
	}

	private function _prepareParameters() {
		foreach ($this-&amp;gt;params as $key =&amp;gt; $value) {
			if(strlen(trim($value)) &amp;gt; 0) {
				$this-&amp;gt;fields .= $key . "=" . urlencode($value) . "&amp;amp;";
			}
		}
	}

	public function getResultResponse() {
		return $this-&amp;gt;results[0];
	}

	public function getResultResponseFull() {
		$response = array (
			"",
			"Approved",
			"Declined",
			"Error"
		);
		return $response[$this-&amp;gt;results[0]];
	}

	public function isApproved() {
		return $this-&amp;gt;approved;
	}

	public function isDeclined() {
		return $this-&amp;gt;declined;
	}

	public function isError() {
		return $this-&amp;gt;error;
	}
	
	public function getTotalAmountPaid() {
		return $this-&amp;gt;results[9];
	}
	
	public function getResponseText() {
		return $this-&amp;gt;results[3];
	}

	public function getAuthCode() {
		return $this-&amp;gt;results[4];
	}

	public function getAVSResponse() {
		return $this-&amp;gt;results[5];
	}

	public function getTransactionID() {
		return $this-&amp;gt;results[6];
	}
	
}


?&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Are there any issues with the code?&lt;/P&gt;</description>
    <pubDate>Fri, 15 Nov 2013 10:16:49 GMT</pubDate>
    <dc:creator>airrent</dc:creator>
    <dc:date>2013-11-15T10:16:49Z</dc:date>
    <item>
      <title>Joomla VIKrentcar integration</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Joomla-VIKrentcar-integration/m-p/36847#M20459</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to integrate my authorize.net account with my joomla component, which has an already built in authorize.net payment gateway.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using https&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code I have from them, and with whom my transactions get denied:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;?php
/**
 * Copyright (c) Extensionsforjoomla.com - E4J - Alessio &amp;lt;tech@extensionsforjoomla.com&amp;gt;
 * 
 * You should have received a copy of the License
 * along with this program.  If not, see &amp;lt;&lt;A href="https://community.developer.cybersource.com/" target="_blank"&gt;http://www.extensionsforjoomla.com/&amp;gt;.&lt;/A&gt;
 * 
 * For any bug, error please contact &amp;lt;tech@extensionsforjoomla.com&amp;gt;
 * We will try to fix it.
 * 
 * Extensionsforjoomla.com - All Rights Reserved
 * 
 */

defined('_JEXEC') OR die('Restricted Area');
error_reporting(0);

class vikRentCarPayment {
	
	private $order_info;
	
	private $login = "1234567thisisok"; //Put you Authorize.net Login ID here
	private $transkey = "12345678910thisisok"; //Put you Authorize.net Transaction Key here
	private $url = "&lt;A href="https://secure.authorize.net/gateway/transact.dll&amp;quot;;" target="_blank"&gt;https://secure.authorize.net/gateway/transact.dll";&lt;/A&gt; //If not testing, use &lt;A href="https://secure.authorize.net/gateway/transact.dll" target="_blank"&gt;https://secure.authorize.net/gateway/transact.dll&lt;/A&gt;
	
	private $params = array();
	private $results = array();
	
	private $approved = false;
	private $declined = false;
	private $error = true;
	
	private $fields;
	private $response;
	
	static $instances = 0;
	
	public function __construct ($order) {
		if (self::$instances == 0) {
			self::$instances++;
			$this-&amp;gt;order_info = $order;
			$this-&amp;gt;params['x_delim_data'] = "TRUE";
			$this-&amp;gt;params['x_delim_char'] = "|";
			$this-&amp;gt;params['x_relay_response'] = "FALSE";
			$this-&amp;gt;params['x_url'] = "FALSE";
			$this-&amp;gt;params['x_version'] = "3.1";
			$this-&amp;gt;params['x_method'] = "CC";
			$this-&amp;gt;params['x_type'] = "AUTH_CAPTURE"; //Change to AUTH_ONLY for not charging the client, see authorize.net for more details
			$this-&amp;gt;params['x_login'] = $this-&amp;gt;login;
			$this-&amp;gt;params['x_tran_key'] = $this-&amp;gt;transkey;
		}else {
			return false;
		}
	}
	
	public function showPayment () {
		$depositmess="";
		$actionurl = $this-&amp;gt;order_info['notify_url'];
		//to enable ssl in the payment validation page decomment the line below
		$actionurl = str_replace('http:', 'https:', $actionurl);
		
		//to enable ssl in the credit card info page decomment the lines below
		if ($_SERVER['HTTPS'] != "on") {
			$url = $this-&amp;gt;order_info['return_url'];
			$mainframe =&amp;amp; JFactory::getApplication();
			$mainframe-&amp;gt;redirect(str_replace('http:', 'https:', $url));
			exit;
		}
		
		$form="&amp;lt;br clear=\"all\"/&amp;gt;&amp;lt;form action=\"".$actionurl."\" method=\"post\" name=\"authorizenetpaymform\"&amp;gt;\n";
		$form.="&amp;lt;table&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCCREDITCARDNUMBER').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"credit_card_number\" name=\"credit_card_number\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.='&amp;lt;tr&amp;gt;&amp;lt;td align="right"&amp;gt;'.JText::_('VRCCVALIDTHROUGH').': &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;select name="expire_month"&amp;gt;
				&amp;lt;option value="01"&amp;gt;January&amp;lt;/option&amp;gt;
				&amp;lt;option value="02"&amp;gt;February&amp;lt;/option&amp;gt;
				&amp;lt;option value="03"&amp;gt;March&amp;lt;/option&amp;gt;
				&amp;lt;option value="04"&amp;gt;April&amp;lt;/option&amp;gt;
				&amp;lt;option value="05"&amp;gt;May&amp;lt;/option&amp;gt;
				&amp;lt;option value="06"&amp;gt;June&amp;lt;/option&amp;gt;
				&amp;lt;option value="07"&amp;gt;July&amp;lt;/option&amp;gt;
				&amp;lt;option value="08"&amp;gt;August&amp;lt;/option&amp;gt;
				&amp;lt;option value="09"&amp;gt;September&amp;lt;/option&amp;gt;
				&amp;lt;option value="10"&amp;gt;October&amp;lt;/option&amp;gt;
				&amp;lt;option value="11"&amp;gt;November&amp;lt;/option&amp;gt;
				&amp;lt;option value="12"&amp;gt;December&amp;lt;/option&amp;gt;
				&amp;lt;/select&amp;gt; ';
		$maxyear = date("Y");
		$form.='&amp;lt;select name="expire_year"&amp;gt;';
		for ($i = $maxyear; $i &amp;lt;= ($maxyear + 10); $i++) {
			$form.='&amp;lt;option value="'.substr($i, -2, 2).'"&amp;gt;'.$i.'&amp;lt;/option&amp;gt;';
		}
		$form.='&amp;lt;/select&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'."\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCCVV').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"credit_card_cvv\" name=\"credit_card_cvv\" size=\"5\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCFIRSTNAME').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_first_name\" name=\"business_first_name\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCLASTNAME').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_last_name\" name=\"business_last_name\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"left\" colspan=\"2\"&amp;gt;&amp;lt;strong&amp;gt;".JText::_('VRCCBILLINGINFO').":&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCCOMPANY').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_company\" name=\"business_company\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCADDRESS').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_address\" name=\"business_address\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCCITY').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_city\" name=\"business_city\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCSTATEPROVINCE').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_state_province\" name=\"business_state_province\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCZIP').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_zipcode\" name=\"business_zipcode\" size=\"5\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCCOUNTRY').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_country\" name=\"business_country\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCPHONE').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_phone\" name=\"business_country\" size=\"15\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\"&amp;gt;".JText::_('VRCCEMAIL').": &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=\"text\" id=\"business_email\" name=\"business_email\" size=\"20\" value=\"\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;tr&amp;gt;&amp;lt;td align=\"right\" colspan=\"2\"&amp;gt;&amp;lt;input type=\"submit\" id=\"authorizenetsubmit\" name=\"authorizenetsubmit\" class=\"button\" value=\"".JText::_('VRCCPROCESSPAY')."\" onclick=\"javascript&amp;amp;colon; event.preventDefault(); this.disabled = true; this.value = '".addslashes(JText::_('VRCCPROCESSING'))."'; document.authorizenetpaymform.submit(); return true;\"/&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\n";
		$form.="&amp;lt;/table&amp;gt;\n";
		$form.="&amp;lt;input type=\"hidden\" name=\"total\" value=\"".number_format(($this-&amp;gt;order_info['total_to_pay'] / 7.6), 2)."\"/&amp;gt;\n";
		$form.="&amp;lt;input type=\"hidden\" name=\"description\" value=\"".$this-&amp;gt;order_info['rooms_name']."\"/&amp;gt;\n";
		$form.="&amp;lt;/form&amp;gt;\n";
		
		if($this-&amp;gt;order_info['leave_deposit']) {
			$depositmess="&amp;lt;br/&amp;gt;&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;".JText::_('VRLEAVEDEPOSIT')." ".number_format($this-&amp;gt;order_info['total_to_pay'], 2)." ".$this-&amp;gt;order_info['currency_symb']."&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;br/&amp;gt;";
		}
		//output form
		echo $depositmess;
		echo $this-&amp;gt;order_info['payment_info']['note'];
		echo $form;
		
		return true;
	}
	
	public function validatePayment () {
		$log="";
		$array_result=array();
		$array_result['verified'] = 0;
		
		//post data
		$creditcard = JRequest :: getString('credit_card_number', '', 'request');
		$expire_month = JRequest :: getString('expire_month', '', 'request');
		$expire_year = JRequest :: getString('expire_year', '', 'request');
		$cvv = JRequest :: getString('credit_card_cvv', '', 'request');
		$total = JRequest :: getString('total', '', 'request');
		//billing information
		$business_first_name = JRequest :: getString('business_first_name', '', 'request');
		self::setParameter('x_first_name', $business_first_name);
		$business_last_name = JRequest :: getString('business_last_name', '', 'request');
		self::setParameter('x_last_name', $business_last_name);
		$business_company = JRequest :: getString('business_company', '', 'request');
		self::setParameter('x_company', $business_company);
		$business_address = JRequest :: getString('business_address', '', 'request');
		self::setParameter('x_address', $business_address);
		$business_city = JRequest :: getString('business_city', '', 'request');
		self::setParameter('x_city', $business_city);
		$business_state_province = JRequest :: getString('business_state_province', '', 'request');
		self::setParameter('x_state', $business_state_province);
		$business_zipcode = JRequest :: getString('business_zipcode', '', 'request');
		self::setParameter('x_zip', $business_zipcode);
		$business_country = JRequest :: getString('business_country', '', 'request');
		self::setParameter('x_country', $business_country);
		$business_phone = JRequest :: getString('business_phone', '', 'request');
		self::setParameter('x_phone', $business_phone);
		$business_email = JRequest :: getString('business_email', '', 'request');
		self::setParameter('x_email', $business_email);
		$description = JRequest :: getString('description', '', 'request');
		self::setParameter('x_description', $description);
		//end billing information
		//end post data
		
		//post data validation
		$error_redirect_url = 'index.php?option=com_vikrentcar&amp;amp;task=vieworder&amp;amp;sid='.$this-&amp;gt;order_info['sid'].'&amp;amp;ts='.$this-&amp;gt;order_info['ts'];
		$valid_data = true;
		$current_month = date("m");
		$current_year = date("y");
		if ((int)$expire_year &amp;lt; (int)$current_year) {
			$valid_data = false;
		} else { 
			if ((int)$expire_year == (int)$current_year) {
				if ((int)$expire_month &amp;lt; (int)$current_month) {
					$valid_data = false;
				}
			}
		}
		if(empty($creditcard)) {
			$valid_data = false;
		}
		if(!$valid_data) {
			JError::raiseWarning('', 'Invalid Data Received for processing the payment, please try again');
			$mainframe =&amp;amp; JFactory::getApplication();
			$mainframe-&amp;gt;redirect($error_redirect_url);
			exit;
		}
		//end post data validation
		
		self::transaction(trim($creditcard), $expire_month.$expire_year, $total, $cvv);
		self::process();
		
		$log = print_r($this-&amp;gt;results, true);
		$array_result['log'] = $log;
		
		if (self::isApproved()) {
			$array_result['verified'] = 1;
			$array_result['tot_paid']=self::getTotalAmountPaid();
		}elseif (self::isDeclined()) {
			$array_result['log'] .= "\nDeclined"; 
		}else {
			$array_result['log'] .= "\nError"; 
		}
		
		return $array_result;
	}
	
	//this function is called after the payment has been validated for redirect actions
	//When this method is called, the class is invoked at the same time as validatePayment()
	public function afterValidation ($esit = 0) {
		$redirect_url = 'index.php?option=com_vikrentcar&amp;amp;task=vieworder&amp;amp;sid='.$this-&amp;gt;order_info['sid'].'&amp;amp;ts='.$this-&amp;gt;order_info['ts'];
		
		if($esit &amp;lt; 1) {
			$responsetxt = self::getResponseText();
			JError::raiseWarning('', (strlen(trim($responsetxt)) &amp;gt; 0 ? $responsetxt.'&amp;lt;br/&amp;gt;' : '').'The payment was not verified, please try again');
		}else {
			$app =&amp;amp; JFactory::getApplication();
			$app-&amp;gt;enqueueMessage('Thank you! The payment was verified successfully');
		}
		
		$mainframe =&amp;amp; JFactory::getApplication();
		$mainframe-&amp;gt;redirect($redirect_url);
		exit;
		//
	}
	
	public function transaction($cardnum, $expiration, $amount, $cvv = "", $invoice = "", $tax = "") {
		$this-&amp;gt;params['x_card_num'] = trim($cardnum);
		$this-&amp;gt;params['x_exp_date'] = trim($expiration);
		$this-&amp;gt;params['x_amount'] = trim($amount);
		$this-&amp;gt;params['x_po_num'] = trim($invoice);
		$this-&amp;gt;params['x_tax'] = trim($tax);
		$this-&amp;gt;params['x_card_code'] = trim($cvv);
	}

	public function process($retries = 3) {
		$this-&amp;gt;_prepareParameters();
		$ch = curl_init($this-&amp;gt;url);
		$count = 0;
		while ($count &amp;lt; $retries) {
			curl_setopt($ch, CURLOPT_HEADER, 0);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim($this-&amp;gt;fields, "&amp;amp; "));
			$this-&amp;gt;response = curl_exec($ch);
			$this-&amp;gt;_parseResults();
			if ($this-&amp;gt;getResultResponseFull() == "Approved") {
				$this-&amp;gt;approved = true;
				$this-&amp;gt;declined = false;
				$this-&amp;gt;error = false;
				break;
			} elseif ($this-&amp;gt;getResultResponseFull() == "Declined") {
				$this-&amp;gt;approved = false;
				$this-&amp;gt;declined = true;
				$this-&amp;gt;error = false;
				break;
			}
			$count++;
		}
		curl_close($ch);
	}

	private function _parseResults() {
		$this-&amp;gt;results = explode("|", $this-&amp;gt;response);
	}

	public function setParameter($param, $value) {
		$param = trim($param);
		$value = trim($value);
		$this-&amp;gt;params[$param] = $value;
	}

	public function setTransactionType($type) {
		$this-&amp;gt;params['x_type'] = strtoupper(trim($type));
	}

	private function _prepareParameters() {
		foreach ($this-&amp;gt;params as $key =&amp;gt; $value) {
			if(strlen(trim($value)) &amp;gt; 0) {
				$this-&amp;gt;fields .= $key . "=" . urlencode($value) . "&amp;amp;";
			}
		}
	}

	public function getResultResponse() {
		return $this-&amp;gt;results[0];
	}

	public function getResultResponseFull() {
		$response = array (
			"",
			"Approved",
			"Declined",
			"Error"
		);
		return $response[$this-&amp;gt;results[0]];
	}

	public function isApproved() {
		return $this-&amp;gt;approved;
	}

	public function isDeclined() {
		return $this-&amp;gt;declined;
	}

	public function isError() {
		return $this-&amp;gt;error;
	}
	
	public function getTotalAmountPaid() {
		return $this-&amp;gt;results[9];
	}
	
	public function getResponseText() {
		return $this-&amp;gt;results[3];
	}

	public function getAuthCode() {
		return $this-&amp;gt;results[4];
	}

	public function getAVSResponse() {
		return $this-&amp;gt;results[5];
	}

	public function getTransactionID() {
		return $this-&amp;gt;results[6];
	}
	
}


?&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Are there any issues with the code?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2013 10:16:49 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Joomla-VIKrentcar-integration/m-p/36847#M20459</guid>
      <dc:creator>airrent</dc:creator>
      <dc:date>2013-11-15T10:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: Joomla VIKrentcar integration</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Joomla-VIKrentcar-integration/m-p/37019#M20545</link>
      <description>&lt;P&gt;It doesn't look like anyone has responded yet, but someone still may have feedback on what you're looking for. I'd recommend subscribing to this topic so that you'll be alerted via email if anyone else from the community is able to respond with any comments. To subscribe, click &lt;STRONG&gt;Topic Options&lt;/STRONG&gt; at the top of this thread and then select &lt;STRONG&gt;Subscribe&lt;/STRONG&gt;. You'll then receive an email once anyone replies to your post.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;Richard&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2013 18:29:36 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Joomla-VIKrentcar-integration/m-p/37019#M20545</guid>
      <dc:creator>RichardH</dc:creator>
      <dc:date>2013-11-21T18:29:36Z</dc:date>
    </item>
  </channel>
</rss>

