126 $this->httpClient->getEventDispatcher()->addListener(
129 if ($event[
'response']->isClientError()) {
130 $event->stopPropagation();
140 $this->
getEndpoint() .
'?' . http_build_query($data),
142 'Accept' =>
'application/json',
143 'Authorization' =>
'Bearer ' . $this->
getToken(),
144 'Content-type' =>
'application/json',
152 'Accept' =>
'application/json',
153 'Authorization' =>
'Bearer ' . $this->
getToken(),
154 'Content-type' =>
'application/json',
166 $httpRequest->getCurlOptions()->set(CURLOPT_SSLVERSION, 6);
169 $body = $httpResponse->getBody(
true);
170 $jsonToArrayResponse = !empty($body) ? $httpResponse->json() : array();
171 return $this->response = $this->
createResponse($jsonToArrayResponse, $httpResponse->getStatusCode());
172 }
catch (\Exception $e) {
173 throw new InvalidResponseException(
174 'Error communicating with payment gateway: ' . $e->getMessage(),
190 public function toJSON($data, $options = 0)
195 if (version_compare(phpversion(),
'5.4.0',
'>=') ===
true) {
198 return str_replace(
'\\/',
'/',
json_encode($data, $options));
203 return $this->response =
new RestResponse($this, $data, $statusCode);