/** * Send the request with specified data * * @param mixed $data The data to send * * @return ResponseInterface */ public function sendData($data) { $request = $this->httpClient->post($this->endpoint)->setBody(Helper::array2xml($data)); $response = $request->send()->getBody(); $responseData = Helper::xml2array($response); return $this->response = new CreateOrderResponse($this, $responseData); }
/** * Send the request with specified data * * @param mixed $data The data to send * * @return ResponseInterface */ public function sendData($data) { $options = array(CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 2, CURLOPT_SSLCERTTYPE => 'PEM', CURLOPT_SSLKEYTYPE => 'PEM', CURLOPT_SSLCERT => $this->getCertPath(), CURLOPT_SSLKEY => $this->getKeyPath()); $body = Helper::array2xml($data); $request = $this->httpClient->post($this->endpoint, null, $data)->setBody($body); $request->getCurlOptions()->overwriteWith($options); $response = $request->send()->getBody(); $responseData = Helper::xml2array($response); return $this->response = new CloseOrderResponse($this, $responseData); }
private function post($url, $data = array(), $timeout = 3) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, Helper::array2xml($data)); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); if (preg_match('#return_code#', $result)) { $result = Helper::xml2array($result); } else { $result = array(['return_code' => 'SUCCESS', 'raw' => $result]); } return $result; }