/** * This function returns full transaction details for a specified transaction ID. * * @link http://www.authorize.net/support/ReportingGuide_XML.pdf * @link http://developer.authorize.net/api/transaction_details/ * @param string $transactionId * @return Varien_Object */ protected function _getTransactionDetails($transactionId) { $requestBody = sprintf('<?xml version="1.0" encoding="utf-8"?>' . '<getTransactionDetailsRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">' . '<merchantAuthentication><name>%s</name><transactionKey>%s</transactionKey></merchantAuthentication>' . '<transId>%s</transId>' . '</getTransactionDetailsRequest>', $this->getConfigData('login'), $this->getConfigData('trans_key'), $transactionId); $client = new Varien_Http_Client(); $uri = $this->getConfigData('cgi_url_td'); $client->setUri($uri ? $uri : self::CGI_URL_TD); $client->setConfig(array('timeout' => 45)); $client->setHeaders(array('Content-Type: text/xml')); $client->setMethod(Zend_Http_Client::POST); $client->setRawData($requestBody); $debugData = array('request' => $requestBody); try { $responseBody = $client->request()->getBody(); $debugData['result'] = $responseBody; $this->_debug($debugData); libxml_use_internal_errors(true); $responseXmlDocument = new Varien_Simplexml_Element($responseBody); libxml_use_internal_errors(false); } catch (Exception $e) { Mage::throwException(Mage::helper('paygate')->__('Payment updating error.')); } $response = new Varien_Object(); $response->setResponseCode((string) $responseXmlDocument->transaction->responseCode)->setResponseReasonCode((string) $responseXmlDocument->transaction->responseReasonCode); return $response; }
/** * Post request to gateway and return response * * @param Varien_Object $request * @return Varien_Object */ protected function _postRequest(Varien_Object $request) { $debugData = array('request' => $request->getData()); $client = new Varien_Http_Client(); $result = new Varien_Object(); $_config = array('maxredirects' => 5, 'timeout' => 30); $_isProxy = $this->getConfigData('use_proxy', false); if ($_isProxy) { $_config['proxy'] = $this->getConfigData('proxy_host') . ':' . $this->getConfigData('proxy_port'); //http://proxy.shr.secureserver.net:3128', $_config['httpproxytunnel'] = true; $_config['proxytype'] = CURLPROXY_HTTP; } $client->setUri($this->_getTransactionUrl())->setConfig($_config)->setMethod(Zend_Http_Client::POST)->setParameterPost($request->getData())->setHeaders('X-VPS-VIT-CLIENT-CERTIFICATION-ID: 33baf5893fc2123d8b191d2d011b7fdc')->setHeaders('X-VPS-Request-ID: ' . $request->getRequestId())->setHeaders('X-VPS-CLIENT-TIMEOUT: ' . $this->_clientTimeout); try { /** * we are sending request to payflow pro without url encoding * so we set up _urlEncodeBody flag to false */ $response = $client->setUrlEncodeBody(false)->request(); } catch (Exception $e) { $result->setResponseCode(-1)->setResponseReasonCode($e->getCode())->setResponseReasonText($e->getMessage()); $debugData['result'] = $result->getData(); $this->_debug($debugData); throw $e; } $response = strstr($response->getBody(), 'RESULT'); $valArray = explode('&', $response); foreach ($valArray as $val) { $valArray2 = explode('=', $val); $result->setData(strtolower($valArray2[0]), $valArray2[1]); } $result->setResultCode($result->getResult())->setRespmsg($result->getRespmsg()); $debugData['result'] = $result->getData(); $this->_debug($debugData); return $result; }
/** * Parses xml response object with full transaction details to Varien_Object * * @param Varien_Simplexml_Element $responseXmlDocument - xml object with full transaction details for a specified transaction ID * @return Varien_Object */ protected function _parseTransactionDetailsXmlResponseToVarienObject(Varien_Simplexml_Element $responseXmlDocument) { $response = new Varien_Object(); $responseTransactionXmlDocument = $responseXmlDocument->transaction; //main fields for generating order status: $response->setResponseCode((string) $responseTransactionXmlDocument->responseCode)->setResponseReasonCode((string) $responseTransactionXmlDocument->responseReasonCode)->setTransactionStatus((string) $responseTransactionXmlDocument->transactionStatus); //some additional fields: isset($responseTransactionXmlDocument->responseReasonDescription) && $response->setResponseReasonDescription((string) $responseTransactionXmlDocument->responseReasonDescription); isset($responseTransactionXmlDocument->FDSFilterAction) && $response->setFdsFilterAction((string) $responseTransactionXmlDocument->FDSFilterAction); isset($responseTransactionXmlDocument->FDSFilters) && $response->setFdsFilters(serialize($responseTransactionXmlDocument->FDSFilters->asArray())); isset($responseTransactionXmlDocument->transactionType) && $response->setTransactionType((string) $responseTransactionXmlDocument->transactionType); isset($responseTransactionXmlDocument->submitTimeUTC) && $response->setSubmitTimeUtc((string) $responseTransactionXmlDocument->submitTimeUTC); isset($responseTransactionXmlDocument->submitTimeLocal) && $response->setSubmitTimeLocal((string) $responseTransactionXmlDocument->submitTimeLocal); return $response; }
public function getLicenseInfo($licensekey, $extensionName, $domain) { $licensekey = trim($licensekey); // check license for old license key if ($oldLicenseInfo = $this->_decrypt($licensekey)) { $license = Mage::getModel('magenotification/license')->loadByLicenseExtension($licensekey, $extensionName); if (!$license->getId()) { // Request first time when using old license key try { $xmlRpc = new Zend_XmlRpc_Client(self::SERVER_URL . 'api/xmlrpc/'); $session = $xmlRpc->call('login', array('username' => self::WEBSERVICE_USER, 'password' => self::WEBSERVICE_PASS)); $result = $xmlRpc->call('call', array('sessionId' => $session, 'apiPath' => 'licensemanager.active', 'args' => array($licensekey, $extensionName, $domain))); $dataObject = new Varien_Object($result); } catch (Exception $e) { return new Varien_Object(array('response_code' => 101)); } $license->setResponseCode($dataObject->getResponseCode())->setDomains($dataObject->getDomains()); if ($dataObject->getActivatedTime()) { $license->setActiveAt(substr($dataObject->getActivatedTime(), 0, 10)); } else { $license->setActiveAt(now(true)); } try { $license->setSumCode($this->_getSumCode($license)); $license->save(); } catch (Exception $e) { } return $dataObject; } $result = new Varien_Object($license->getData()); $result->addData(array('users' => 1, 'created_time' => date('Y-m-d H:m:s', $oldLicenseInfo['created_time']), 'activated_time' => $license->getActiveAt(), 'type' => $oldLicenseInfo['type'], 'status' => 1, 'expired_time' => $oldLicenseInfo['expired_time'])); if ($license->getSumCode() != $this->_getSumCode($license)) { try { $license->setResponseCode(self::GENERAL_ERROR); $license->setSumCode($this->_getSumCode($license))->save(); } catch (Exception $e) { } } elseif ($result->getType() == self::TRIAL_VERSION && $license->getResponseCode() > self::LIMITED_DOMAIN_ERROR) { $expiredTime = strtotime($license->getActiveAt()) + (int) $result->getExpiredTime() * 24 * 3600; if ($expiredTime < time()) { try { $license->setResponseCode(self::EXPIRED_TRIAL_LICENSE_KEY_ERROR); $license->setSumCode($this->_getSumCode($license))->save(); } catch (Exception $e) { } } } return $result->setResponseCode($license->getResponseCode()); } // check new license key if ($licenseInfo = $this->_newkeyDecrypt($licensekey, $extensionName, $domain)) { $license = Mage::getModel('magenotification/license')->loadByLicenseExtension($licensekey, $extensionName); if (!$license->getId()) { $license->setActiveAt(now(true))->setDomains($licenseInfo->getDomains()); $responseCode = self::NEW_DOMAIN_SUCCESS; $licenseDomain = strlen($domain) > 38 ? substr($domain, 0, 38) : $domain; if ($licenseDomain != $licenseInfo->getDomains()) { $responseCode = self::LIMITED_DOMAIN_ERROR; } try { $license->setResponseCode($responseCode); $license->setSumCode($this->_getSumCode($license))->save(); } catch (Exception $e) { } } $result = new Varien_Object($license->getData()); $createdTime = $licenseInfo->getCreatedDate() ? $licenseInfo->getCreatedDate() : $license->getActiveAt(); $result->addData(array('users' => 1, 'created_time' => date('Y-m-d H:m:s', strtotime($createdTime)), 'activated_time' => $license->getActiveAt(), 'type' => $this->getOldLicenseType($licenseInfo->getType()), 'status' => 1, 'expired_time' => $licenseInfo->getExpiredTime())); if ($license->getSumCode() != $this->_getSumCode($license)) { try { $license->setResponseCode(self::GENERAL_ERROR); $license->setSumCode($this->_getSumCode($license))->save(); } catch (Exception $e) { } } elseif (($result->getType() == self::TRIAL_VERSION || $result->getType() == self::DEVELOPMENT) && $license->getResponseCode() > self::LIMITED_DOMAIN_ERROR) { $expiredTime = strtotime($license->getActiveAt()) + (int) $result->getExpiredTime() * 24 * 3600; if ($expiredTime < time()) { try { $license->setResponseCode(self::EXPIRED_TRIAL_LICENSE_KEY_ERROR); $license->setSumCode($this->_getSumCode($license))->save(); } catch (Exception $e) { } } } return $result->setResponseCode($license->getResponseCode()); } return new Varien_Object(array('response_code' => self::GENERAL_ERROR)); }
private function _tokenWorker($token, $request) { $base64ClientID = base64_encode($this->_clientId . ":" . $this->_clientSecret); $client = new Varien_Http_Client(); $result = new Varien_Object(); $_config = array('maxredirects' => 5, 'timeout' => 5); $client->setUri($this->getAccessTokenEndPoint())->setConfig($_config)->setMethod(Zend_Http_Client::POST)->setParameterPost($request->getData())->setHeaders('User-Agent: Varien_Http_Client')->setHeaders('Authorization: Basic ' . $base64ClientID)->setHeaders('Accept: */*'); try { $response = $client->setUrlEncodeBody(false)->request(); } catch (Exception $e) { $result->setResponseCode(-1)->setResponseReasonCode($e->getCode())->setResponseReasonText($e->getMessage()); $debugData['result'] = $result->getData(); $this->_debug($debugData); throw new Mage_Exception($e->getMessage()); return false; } $body = Mage::helper('core')->jsonDecode($response->getBody()); $result->addData($body); $debugData['result'] = $result->getData(); $this->_debug($debugData); if (isset($debugData['result']['error'])) { Mage::log($debugData['result']['error_description']); return false; } return $result; }