$value) { $method = 'set' . ucfirst($key); if (method_exists($this, $method)) { $this->$method($value); } else { $this->_options[$key] = $value; } } return $this; } public function setLogin($login) { $this->_login = $login; } public function setTransactionKey($transactionKey) { $this->_transactionKey = $transactionKey; } public function setTestRequest($testRequest) { $this->_testRequest = ($testRequest) ? 'TRUE' : 'FALSE'; } protected function _getUrl() { if ($this->_testRequest === 'FALSE') { $this->_url = 'https://secure.authorize.net/gateway/transact.dll'; } else { $this->_url = 'https://test.authorize.net/gateway/transact.dll'; } return $this->_url; } public function captureCreditCard($request) { $request['x_type'] = 'AUTH_CAPTURE'; $request['x_method'] = 'CC'; return $this->_sendRequest($request); } protected function _sendRequest(array $request) { $request['x_login'] = $this->_login; $request['x_tran_key'] = $this->_transactionKey; $request['x_version'] = $this->_version; $request['x_delim_data'] = 'TRUE'; $request['x_delim_char'] = '|'; $request['x_relay_response'] = 'FALSE'; $postString = ""; foreach ($request as $name => $value) { $postString .= $name . '=' . urlencode($value) . '&'; } $postString = rtrim($postString, '& '); $ch = curl_init($this->_getUrl()); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postString); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); curl_close($ch); $responseData = explode($request['x_delim_char'], $response); return $responseData; } }