/** * &execute() * * @access public * @param string $sUrl * @param array $aryPostFields * @param string $sEncode * @return mixed string | PEAR_Error */ function &execute($sUrl = '', $aryPostFields = array(), $sEncode = '') { if (!is_resource($this->_ch)) { $objRet = parent::create(); if (PEAR::isError($objRet)) { return $objRet; } $this->verifyPeer = -1; $this->verifyHost = -1; } if ('' != $sUrl) { $this->setUrl($sUrl); } if (!empty($aryPostFields)) { $this->setPostFields($aryPostFields); } foreach ($this->_aryOptions as $iOption => $mValue) { if (!curl_setopt($this->_ch, $iOption, $mValue)) { return PEAR::raiseError('Error setting Options'); } } $sRet = parent::execute(); parent::close(); if ('' != $sUrl) { $this->clearUrl(); } if (!empty($aryPostFields)) { $this->clearPostFields(); } if (PEAR::isError($sRet)) { return $sRet; } if ('' != $sEncode) { $sRet = mb_convert_encoding($sRet, 'UTF-8', $sEncode); } return $sRet; }
/** * Process the transaction. * * @author Joe Stump <*****@*****.**> * @access public * @return mixed Payment_Process_Result on success, PEAR_Error on failure */ function &process() { if (!strlen($this->_options['keyfile']) || !file_exists($this->_options['keyfile'])) { return PEAR::raiseError('Invalid key file'); } // Sanity check $result = $this->validate(); if (PEAR::isError($result)) { return $result; } // Prepare the data $result = $this->_prepare(); if (PEAR::isError($result)) { return $result; } // Don't die partway through PEAR::pushErrorHandling(PEAR_ERROR_RETURN); $xml = $this->_prepareQueryString(); if (PEAR::isError($xml)) { return $xml; } $url = 'https://' . $this->_options['host'] . ':' . $this->_options['port'] . '/LSGSXML'; $curl = new Net_Curl($url); $result = $curl->create(); if (PEAR::isError($result)) { return $result; } $curl->type = 'POST'; $curl->fields = $xml; $curl->sslCert = $this->_options['keyfile']; // LinkPoint's staging server has a boned certificate. If they are // testing against staging we need to turn off SSL host verification. if ($this->_options['host'] == 'staging.linkpt.net') { $curl->verifyPeer = false; $curl->verifyHost = 0; } $curl->userAgent = 'PEAR Payment_Process_LinkPoint 0.1'; $result =& $curl->execute(); if (PEAR::isError($result)) { return PEAR::raiseError('cURL error: ' . $result->getMessage()); } else { $curl->close(); } $this->_responseBody = trim($result); $this->_processed = true; // Restore error handling PEAR::popErrorHandling(); $response =& Payment_Process_Result::factory($this->_driver, $this->_responseBody, $this); if (!PEAR::isError($response)) { $response->parse(); } return $response; }