<?php
class Authorize_model extends CI_Model
{

	public function __construct()
	{
		parent::__construct();
		$this->load->library('AuthorizeDotNet');
	}

	function doDirectPayment ($total_amount, $currencyCodeType, $orderRowId)
	{
		$getInstance = &get_instance();
		$getInstance->load->model('paymentModel/Paypal_model', 'Paypal_model', TRUE);
		$apiInfo = $getInstance->Paypal_model->getMerchantAPIInformation($orderRowId);
		$getInstance->load->model('orders/Order_model', 'Order_model', TRUE);
		$getInstance->load->model('customers/Customer_Setup_model', 'Customer_Setup_model', TRUE);
		$getInstance->load->model('merchant/Merchant_model', 'Merchant_model', TRUE);
		/**
		 * To Initialize (before use of initializeIt) the authorize.net Account
		 * we must set login & Transaction key with correct key
		 */
		$this->authorizedotnet->login = $apiInfo->authorize_api_login_key; //Merchant API Login ID
		$this->authorizedotnet->transkey = $apiInfo->authorize_api_transaction_key; //Merchant Transaction Key
		$this->authorizedotnet->initializeIt();
		$this->authorizedotnet->setReceipt("<a href='" . BASEURL . "'>".$this->config->item('project_name')."</a>", 'copyright (c)' . $this->config->item('project_name'));
		/**
		 * Get Order Information Details
		 */
		$orderInfo = $getInstance->Order_model->getOrderByRowId($orderRowId);
		$customerIP = $orderInfo->from_ip_address;
		$this->authorizedotnet->setCustomerIP($customerIP);
		$customer_id = $orderInfo->customer_id;
		$merchant_row_id = $orderInfo->merchant_row_id;
		//$data['customer_info'] = $getInstance->Customer_Setup_model->getCustomerWithCardInfo($customer_id);
        $data['customer_info'] = $getInstance->Customer_Setup_model->getCustomerByOrderRowId($orderRowId);
		$data['merchant_info'] = $getInstance->Merchant_model->getMerchantDetails($merchant_row_id);
		$customerFirstName = $data['customer_info']->first_name;
		$customerLastName = $data['customer_info']->last_name;
		$customerEmail = $data['customer_info']->customer_email;
		#$cardType = $data ['customer_info']->card_type;
		$cardNumber = $data['customer_info']->card_number;
		$cardExpirationMonth = $data['customer_info']->card_exp_month;
		$cardExpirationYear = $data['customer_info']->card_exp_year;
		$cardExpirationValue = $cardExpirationMonth . $cardExpirationYear;
		#$cardContactName = $data ['customer_info']->card_holder_contactname;
		$billAddressLine1 = $data['customer_info']->address_line1;
		$billAddressLine2 = $data['customer_info']->address_line2;
		$billAddress = $billAddressLine1 . " " . $billAddressLine2;
		$billAddressCompany = $data['customer_info']->company_name;
		$billAddressCity = $data['customer_info']->customer_city;
		$billAddressState = $data['customer_info']->customer_state;
		$billAddressZip = $data['customer_info']->customer_zip;
		$billAddressCountry = $data['customer_info']->country;
		$billAddressHomePhone = $data['customer_info']->home_phone_number;
		$billAddressWorkPhone = $data['customer_info']->work_phone_number;

		if (! empty($billAddressHomePhone))
		{
			$billAddressPhone = $billAddressHomePhone . " (Home)";
		}
		if ((! empty($billAddressHomePhone)) && (! empty($billAddressWorkPhone)))
		{
			$billAddressPhone .= " , " . $billAddressWorkPhone . " (Work)";
		} else
		{
			$billAddressPhone = $billAddressWorkPhone . " (Work)";
		}
		$billAddressFAX = $data['customer_info']->fax;
		$shippingCustomerName = $data['customer_info']->shipping_name;
		$shipAddressLine1 = $data['customer_info']->shipping_address_line1;
		$shipAddressLine2 = $data['customer_info']->shipping_address_line2;
		$shipAddress = $shipAddressLine1 . " " . $shipAddressLine2;
		$shipAddressCompanyName = $data['customer_info']->shipping_company_name;
		$shipAddressCity = $data['customer_info']->shipping_customer_city;
		$shipAddressState = $data['customer_info']->shipping_customer_state;
		$shipAddressZip = $data['customer_info']->shipping_customer_zip;
		$shipAddressCountry = $data['customer_info']->shipping_country;
		$merchantEmailAddress = $data['merchant_info']->email_address;
		$this->authorizedotnet->setCustomerId($customer_id);
		$this->authorizedotnet->setTransaction($cardNumber, $cardExpirationValue, $total_amount, $currencyCodeType);//, $cardVerificationNumber);
		/**
		 * @version PWC1.2
		 * @desc add $description text
		 */
		$description = 'Product buy from <a href="'.$data['merchant_info']->website_url.'">'.$data['merchant_info']->company_name.'</a>';
		$this->authorizedotnet->setPaymentDetails($description);
		$this->authorizedotnet->setCustomer($customerFirstName, $customerLastName, $customerEmail);
		$this->authorizedotnet->setMerchantEmail($merchantEmailAddress);
		$this->authorizedotnet->setCustomerBillAddress($billAddress, $billAddressCompany, $billAddressCity, $billAddressState, $billAddressZip, $billAddressCountry, $billAddressPhone, $billAddressFAX);
		$this->authorizedotnet->setCustomerShippingAddress($shippingCustomerName, '', $shipAddressCompanyName, $shipAddress, $shipAddressCity, $shipAddressState, $shipAddressZip, $shipAddressCountry);
		$this->authorizedotnet->process();

		$paymentDetails['reason_code'] = $this->authorizedotnet->getResponseReasonCode();
        $paymentDetails['response_code'] = $this->authorizedotnet->getResponseCode();
        $paymentDetails['response_reason_code'] = $this->authorizedotnet->getResponseReasonCode();

		#$paymentDetails['payment_status'] = $this->authorizedotnet->getResponseReasonCode();
		#$paymentDetails['pending_reason'] = $resArray['nvpResArray']['PENDINGREASON'];
		$paymentDetails['payment_gateway'] = $this->config->item('payment_gateway_authorize_dot_net');
		$paymentDetails['amount'] = $this->authorizedotnet->getAmount();
		#$paymentDetails['curl_error_number'] = $resArray['curlError']['curl_error_no'];
		$paymentDetails['curl_error_message'] = addslashes($this->authorizedotnet->errorDetails);

		#$paymentDetails['correlation_id'] = $resArray['nvpResArray']['CORRELATIONID'];
		$paymentDetails['version'] = $this->authorizedotnet->params['x_version'];
		$paymentDetails['auth_code'] = $this->authorizedotnet->getAuthCode();
		$paymentDetails['transaction_id'] = $this->authorizedotnet->getTransactionID();
		$paymentDetails['transaction_type'] = $this->authorizedotnet->getTransactionType();

        if(($this->authorizedotnet->error)||($this->authorizedotnet->declined))
		{
			$paymentDetails['success'] = 0;
			$paymentDetails['ack'] = 'Failure';
		}
		else
		{
			$paymentDetails['success'] = 1;
			$paymentDetails['ack'] = 'Success';
		}

		$paymentDetails['error_text'] = addslashes($this->authorizedotnet->errorDetails);

		$_SESSION['paymentDetails'] = $paymentDetails;

		if (($this->authorizedotnet->error)||($this->authorizedotnet->declined))
		{
			$_SESSION['reshash']['curlError']['curl_error_msg'] = $this->authorizedotnet->errorDetails;
			redirect('paymentMethods/payment_utility/paymentAPIError/' . $orderRowId);
		}
		else
		{
			redirect('paymentMethods/payment_utility/paymentSuccess/' . $orderRowId);
		}
	}


	/**
	 * @author Jilani Jidni
	 * make current recurring payment with authorize.net
	 * @version PWC1.2
	 * @desc Remove credit card cvv2 number
	 *
	 */
	function doDirectPaymentForRecurring ($paymentInfo)
	{
		$getInstance = &get_instance();
		$getInstance->load->model('carts/Cart_Setup_model', 'Cart_Setup_model', TRUE);
		$apiInfo = $getInstance->Cart_Setup_model->getGatewaySetup($paymentInfo['merchant_row_id']);
		/**
		 * To Initialize (before use of initializeIt) the authorize.net Account
		 * we must set login & Transaction key with correct key
		 */
		$this->authorizedotnet->login = $apiInfo->authorize_api_login_key; //Merchant API Login ID
		$this->authorizedotnet->transkey = $apiInfo->authorize_api_transaction_key; //Merchant Transaction Key
		$this->authorizedotnet->initializeIt();
		$this->authorizedotnet->setReceipt("<a href='" . BASEURL . "'>Premium Web Cart</a>", 'copyright (c)' . $this->config->item('project_name'));
		$customerFirstName = $paymentInfo['first_name'];
		$customerLastName = $paymentInfo['last_name'];
		$customerEmail = $paymentInfo['customer_email'];
		#$cardType = $data ['customer_info']->card_type;
		$cardNumber = $paymentInfo['card_number'];
		$cardExpirationMonth = $paymentInfo['expiration_month'];
		$cardExpirationYear = $paymentInfo['expiration_year'];
		$cardExpirationValue = $cardExpirationMonth . $cardExpirationYear;
		$billAddressLine1 = $paymentInfo['address_1'];
		$billAddressLine2 = $paymentInfo['address_2'];
		$billAddress = $billAddressLine1 . " " . $billAddressLine2;
		$billAddressCompany = $paymentInfo['company'];
		$billAddressCity = $paymentInfo['city'];
		$billAddressState = $paymentInfo['state'];
		$billAddressZip = $paymentInfo['zip_code'];
		$billAddressCountry = $paymentInfo['country'];
		$billAddressHomePhone = $paymentInfo['homePhone'];
		$billAddressWorkPhone = $paymentInfo['workPhone'];
		if (! empty($billAddressHomePhone))
		{
			$billAddressPhone = $billAddressHomePhone . " (Home)";
		}
		if ((! empty($billAddressHomePhone)) && (! empty($billAddressWorkPhone)))
		{
			$billAddressPhone .= " , " . $billAddressWorkPhone . " (Work)";
		} else
		{
			$billAddressPhone = $billAddressWorkPhone . " (Work)";
		}
		$billAddressFAX = $paymentInfo['fax'];
		$amount = $paymentInfo['amount'];
		$currencyCodeType = $paymentInfo['currencyCodeType'];
		$this->authorizedotnet->setTransaction($cardNumber, $cardExpirationValue, $amount, $currencyCodeType);
		$this->authorizedotnet->setCustomer($customerFirstName, $customerLastName, $customerEmail);
		$this->authorizedotnet->setCustomerBillAddress($billAddress, $billAddressCompany, $billAddressCity, $billAddressState, $billAddressZip, $billAddressCountry, $billAddressPhone, $billAddressFAX);
		$this->authorizedotnet->process();
		$paymentResponse['response']['transaction_id'] = $this->authorizedotnet->getTransactionID();
		$paymentResponse['response']['avs_code'] = $this->authorizedotnet->getAuthCode();
        $paymentResponse['response']['response_code'] = $this->authorizedotnet->getResponseCode();
        $paymentResponse['response']['response_reason_code'] = $this->authorizedotnet->getResponseReasonCode();
		/**
		 * add declied
		 */
		if(($this->authorizedotnet->error)||($this->authorizedotnet->declined))
		{
			$paymentResponse['response']['success'] = 0;
			$paymentResponse['response']['ack'] = 'Failure';
		}
		else
		{
			$paymentResponse['response']['success'] = 1;
			$paymentResponse['response']['ack'] = 'Success';
		}

		#$paymentResponse['response']['success'] = ($this->authorizedotnet->error) ? 0 : 1;
		#$paymentResponse['response']['ack'] = ($this->authorizedotnet->error) ? 'Failure' : 'Success';
		$paymentResponse['response']['error_text'] = $this->authorizedotnet->errorDetails;
		return $paymentResponse;
	}

	function refundTransaction($paymentInfo,$orderRowId)
	{   
		$getInstance = &get_instance();
		$getInstance->load->model('paymentModel/Paypal_model', 'Paypal_model', TRUE);
		$apiInfo = $getInstance->Paypal_model->getMerchantAPIInformation($orderRowId);
		$getInstance->load->model('orders/Order_model', 'Order_model', TRUE);
		$getInstance->load->model('customers/Customer_Setup_model', 'Customer_Setup_model', TRUE);
		$getInstance->load->model('merchant/Merchant_model', 'Merchant_model', TRUE);
		/**
		 * To Initialize (before use of initializeIt) the authorize.net Account
		 * we must set login & Transaction key with correct key
		 */
		$this->authorizedotnet->login = $apiInfo->authorize_api_login_key; //Merchant API Login ID
		$this->authorizedotnet->transkey = $apiInfo->authorize_api_transaction_key; //Merchant Transaction Key

		$this->authorizedotnet->initializeIt();
		$this->authorizedotnet->params['x_type'] = 'CREDIT';
		$this->authorizedotnet->params['x_trans_id'] = $paymentInfo['transactionID'];

		$this->authorizedotnet->setReceipt("<a href='" . base_url() . "'>".$this->config->item('project_name')."</a>", 'copyright (c)' . $this->config->item('project_name'));
		/**
		 * Get Order Information Details
		 */
		$orderInfo = $getInstance->Order_model->getOrderByRowId($orderRowId);
		$customerIP = $orderInfo->from_ip_address;
		$this->authorizedotnet->setCustomerIP($customerIP);
		$customer_id = $orderInfo->customer_id;
		$merchant_row_id = $orderInfo->merchant_row_id;
		//$data['customer_info'] = $getInstance->Customer_Setup_model->getCustomerWithCardInfo($customer_id);
        $data['customer_info'] = $getInstance->Customer_Setup_model->getCustomerByOrderRowId($orderRowId);
		$data['merchant_info'] = $getInstance->Merchant_model->getMerchantDetails($merchant_row_id);
		$customerFirstName = $data['customer_info']->first_name;
		$customerLastName = $data['customer_info']->last_name;
		$customerEmail = $data['customer_info']->customer_email;
		#$cardType = $data ['customer_info']->card_type;
		$cardNumber = $data['customer_info']->card_number;
		$cardExpirationMonth = $data['customer_info']->card_exp_month;
		$cardExpirationYear = $data['customer_info']->card_exp_year;
		$cardExpirationValue = str_pad($cardExpirationMonth,2,0,'LEFT').$cardExpirationYear;
		#$cardContactName = $data ['customer_info']->card_holder_contactname;
		$billAddressLine1 = $data['customer_info']->address_line1;
		$billAddressLine2 = $data['customer_info']->address_line2;
		$billAddress = $billAddressLine1 . " " . $billAddressLine2;
		$billAddressCompany = $data['customer_info']->company_name;
		$billAddressCity = $data['customer_info']->customer_city;
		$billAddressState = $data['customer_info']->customer_state;
		$billAddressZip = $data['customer_info']->customer_zip;
		$billAddressCountry = $data['customer_info']->country;
		$billAddressHomePhone = $data['customer_info']->home_phone_number;
		$billAddressWorkPhone = $data['customer_info']->work_phone_number;

		if (! empty($billAddressHomePhone))
		{
			$billAddressPhone = $billAddressHomePhone . " (Home)";
		}
		if ((! empty($billAddressHomePhone)) && (! empty($billAddressWorkPhone)))
		{
			$billAddressPhone .= " , " . $billAddressWorkPhone . " (Work)";
		}
        else
		{
			$billAddressPhone = $billAddressWorkPhone . " (Work)";
		}
		$billAddressFAX = $data['customer_info']->fax;
		$shipAddressLine1 = $data['customer_info']->shipping_address_line1;
		$shipAddressLine2 = $data['customer_info']->shipping_address_line2;
		$shipAddress = $shipAddressLine1 . " " . $shipAddressLine2;
		$shipAddressCompanyName = $data['customer_info']->shipping_company_name;
		$shipAddressCity = $data['customer_info']->shipping_customer_city;
		$shipAddressState = $data['customer_info']->shipping_customer_state;
		$shipAddressZip = $data['customer_info']->shipping_customer_zip;
		$shipAddressCountry = $data['customer_info']->shipping_country;
		$merchantEmailAddress = $data['merchant_info']->email_address;

		$this->authorizedotnet->setCustomerId($customer_id);

		$this->authorizedotnet->setTransaction($cardNumber, $cardExpirationValue, $paymentInfo['amount'], $paymentInfo['currency']);
		/**
		 * @version PWC1.2
		 * @desc add Payment description
		 */
		$this->authorizedotnet->setPaymentDetails($paymentInfo['memo']);
		$this->authorizedotnet->setCustomer($customerFirstName, $customerLastName, $customerEmail);
		$this->authorizedotnet->setMerchantEmail($merchantEmailAddress);
		$this->authorizedotnet->setCustomerBillAddress($billAddress, $billAddressCompany, $billAddressCity, $billAddressState, $billAddressZip, $billAddressCountry, $billAddressPhone, $billAddressFAX);
		$this->authorizedotnet->setCustomerShippingAddress($customerFirstName, $customerLastName, $shipAddressCompanyName, $shipAddress, $shipAddressCity, $shipAddressState, $shipAddressZip, $shipAddressCountry);

		$this->authorizedotnet->process();

		$paymentDetails['reason_code'] = $this->authorizedotnet->getResponseReasonCode();
		#$paymentDetails['payment_status'] = $this->authorizedotnet->getResponseReasonCode();
		#$paymentDetails['pending_reason'] = $resArray['nvpResArray']['PENDINGREASON'];
		$paymentDetails['payment_gateway'] = $this->config->item('payment_gateway_authorize_dot_net');
		$paymentDetails['amount'] = $this->authorizedotnet->getAmount();
		#$paymentDetails['curl_error_number'] = $resArray['curlError']['curl_error_no'];
		$paymentDetails['curl_error_message'] = addslashes($this->authorizedotnet->errorDetails);
		#$paymentDetails['correlation_id'] = $resArray['nvpResArray']['CORRELATIONID'];
		$paymentDetails['version'] = $this->authorizedotnet->params['x_version'];
		$paymentDetails['auth_code'] = $this->authorizedotnet->getAuthCode();
		$paymentDetails['transaction_id'] = $this->authorizedotnet->getTransactionID();
		$paymentDetails['transaction_type'] = $this->authorizedotnet->getTransactionType();
        $paymentDetails['response_code'] = $this->authorizedotnet->getResponseCode();
        $paymentDetails['response_reason_code'] = $this->authorizedotnet->getResponseReasonCode();

		/**
		 * add declied
		 */
		if(($this->authorizedotnet->error)||($this->authorizedotnet->declined))
		{
			$paymentDetails['success'] = 0;
			$paymentDetails['ack'] = 'Failure';
		}
		else
		{
			$paymentDetails['success'] = 1;
			$paymentDetails['ack'] = 'Success';
		}

		#$paymentDetails['ack'] = ($this->authorizedotnet->error) ? 'Failure' : 'Success';
		#$paymentDetails['success'] = ($this->authorizedotnet->error) ? 0 : 1;
		$paymentDetails['error_text'] = addslashes($this->authorizedotnet->errorDetails);

		return $paymentDetails;
	}

	function merchantRefundTransaction($paymentInfo,$admin_gateway_row_id,$merchant_row_id)
	{
		$getInstance = &get_instance();
		$getInstance->load->model('paymentModel/Paypal_model', 'Paypal_model', TRUE);
		$apiInfo = $getInstance->Paypal_model->getMerchantAPIInformationUsingAdminGatewayRowId($admin_gateway_row_id);

		$getInstance->load->model('orders/Order_model', 'Order_model', TRUE);
		$getInstance->load->model('customers/Customer_Setup_model', 'Customer_Setup_model', TRUE);
		$getInstance->load->model('merchant/Merchant_model', 'Merchant_model', TRUE);
		/**
		 * To Initialize (before use of initializeIt) the authorize.net Account
		 * we must set login & Transaction key with correct key
		 */
		$this->authorizedotnet->login = $apiInfo->authorize_api_login_key; //Merchant API Login ID
		$this->authorizedotnet->transkey = $apiInfo->authorize_api_transaction_key; //Merchant Transaction Key
		$this->authorizedotnet->initializeIt();

		$this->authorizedotnet->params['x_type'] = 'CREDIT';

		$this->authorizedotnet->params['x_trans_id'] = $paymentInfo['transactionID'];

		$this->authorizedotnet->setReceipt("<a href='" . BASEURL . "'>".$this->config->item('project_name')."</a>", 'copyright (c)' . $this->config->item('project_name'));

		/**
		 * Get Order Information Details
		 */
		/*$orderInfo = $getInstance->Order_model->getOrderByRowId($orderRowId);
		$customerIP = $orderInfo->from_ip_address;
		$this->authorizedotnet->setCustomerIP($customerIP);
		$customer_id = $orderInfo->customer_id;
		$merchant_row_id = $orderInfo->merchant_row_id;
		$data['customer_info'] = $getInstance->Customer_Setup_model->getCustomer($customer_id);*/
		$data['merchant_info'] = $getInstance->Merchant_model->getMerchantDetails($merchant_row_id);
		$data['merchant_billing_info'] = $getInstance->Merchant_model->getMerchantBillingInfoWithCardNumber($merchant_row_id);

		$merchantFirstName = $data['merchant_info']->first_name;
		$merchantLastName = $data['merchant_info']->last_name;
		$merchantEmail = $data['merchant_info']->email_address;
		#$cardType = $data ['customer_info']->card_type;
		$cardNumber = $data['merchant_billing_info']['card_number'];
		$cardExpirationMonth = $data['merchant_billing_info']['card_exp_month'];
		$cardExpirationYear = $data['merchant_billing_info']['card_exp_year'];
		$cardExpirationValue = $cardExpirationMonth . $cardExpirationYear;
		#$cardContactName = $data ['customer_info']->card_holder_contactname;

		$billAddress = $data['merchant_billing_info']['billing_address'];
		$billAddressCompany = $data['merchant_billing_info']['billing_company'];
		$billAddressCity = $data['merchant_billing_info']['billing_city'];
		$billAddressState = $data['merchant_billing_info']['billing_state'];
		$billAddressZip = $data['merchant_billing_info']['billing_zip_code'];
		$billAddressCountry = $data['merchant_billing_info']['billing_country'];
		$billAddressContactPhone = $data['merchant_billing_info']['billing_phone'];

		/*$billAddressFAX = $data['customer_info']->fax;
		$shipAddressLine1 = $data['customer_info']->shipping_address_line1;
		$shipAddressLine2 = $data['customer_info']->shipping_address_line2;
		$shipAddress = $shipAddressLine1 . " " . $shipAddressLine2;
		$shipAddressCompanyName = $data['customer_info']->shipping_company_name;
		$shipAddressCity = $data['customer_info']->shipping_customer_city;
		$shipAddressState = $data['customer_info']->shipping_customer_state;
		$shipAddressZip = $data['customer_info']->shipping_customer_zip;
		$shipAddressCountry = $data['customer_info']->shipping_country;
		*/
		#$merchantEmailAddress = $data['merchant_info']->email_address;
		$this->authorizedotnet->setCustomerId($merchant_row_id);
		$this->authorizedotnet->setTransaction($cardNumber, $cardExpirationValue, $paymentInfo['amount'], $paymentInfo['currency']);

		/**
		 * @version PWC1.2
		 * @desc add Payment description
		 */
		$this->authorizedotnet->setPaymentDetails($paymentInfo['memo']);
		$this->authorizedotnet->setCustomer($merchantFirstName, $merchantLastName,$merchantEmail);
		#$this->authorizedotnet->setMerchantEmail($merchantEmailAddress);
		$this->authorizedotnet->setMerchantEmail($merchantEmail);
		$this->authorizedotnet->setCustomerBillAddress($billAddress, $billAddressCompany, $billAddressCity, $billAddressState, $billAddressZip, $billAddressCountry, $billAddressContactPhone);
		#$this->authorizedotnet->setCustomerShippingAddress($customerFirstName, $customerLastName, $shipAddressCompanyName, $shipAddress, $shipAddressCity, $shipAddressState, $shipAddressZip, $shipAddressCountry);
		$this->authorizedotnet->process();

		$paymentDetails['reason_code'] = $this->authorizedotnet->getResponseReasonCode();
		#$paymentDetails['payment_status'] = $this->authorizedotnet->getResponseReasonCode();
		#$paymentDetails['pending_reason'] = $resArray['nvpResArray']['PENDINGREASON'];
		$paymentDetails['payment_gateway'] = $this->config->item('payment_gateway_authorize_dot_net');
		$paymentDetails['amount'] = $this->authorizedotnet->getAmount();
		#$paymentDetails['curl_error_number'] = $resArray['curlError']['curl_error_no'];
		$paymentDetails['curl_error_message'] = addslashes($this->authorizedotnet->errorDetails);
		#$paymentDetails['correlation_id'] = $resArray['nvpResArray']['CORRELATIONID'];
		$paymentDetails['version'] = $this->authorizedotnet->params['x_version'];
		$paymentDetails['auth_code'] = $this->authorizedotnet->getAuthCode();
		$paymentDetails['transaction_id'] = $this->authorizedotnet->getTransactionID();
		$paymentDetails['transaction_type'] = $this->authorizedotnet->getTransactionType();
        $paymentDetails['response_code'] = $this->authorizedotnet->getResponseCode();
        $paymentDetails['response_reason_code'] = $this->authorizedotnet->getResponseReasonCode();

		/**
		 * add declied
		 */
		if(($this->authorizedotnet->error)||($this->authorizedotnet->declined))
		{
			$paymentDetails['success'] = 0;
			$paymentDetails['ack'] = 'Failure';
		}
		else
		{
			$paymentDetails['success'] = 1;
			$paymentDetails['ack'] = 'Success';
		}

		$paymentDetails['error_text'] = addslashes($this->authorizedotnet->errorDetails);

		return $paymentDetails;
	}
}
?>