diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index aa85c1d..a1f4283 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -156,14 +156,19 @@ public function sendData($data) { $url = $this->getEndPoint() . $this->getMethod(); $this->validate('userName', 'password'); + $data = array_merge( + [ + 'userName' => $this->getUserName(), + 'password' => $this->getPassword(), + ], + $data + ); + $httpResponse = $this->httpClient->request( $this->getHttpMethod(), $url, $this->getHeaders(), - json_encode(array_merge([ - 'userName' => $this->getUserName(), - 'password' => $this->getPassword() - ], $data)) + http_build_query($data, '', '&') ); $responseClassName = str_replace('Request', 'Response', \get_class($this)); @@ -174,7 +179,9 @@ public function sendData($data) ); } - return $reflection->newInstance($this, json_decode($httpResponse->getBody(true), true)); + $content = json_decode($httpResponse->getBody()->getContents(), true); + + return $reflection->newInstance($this, $content); } /** diff --git a/src/Message/AuthorizeRequest.php b/src/Message/AuthorizeRequest.php index 57ef5dc..0f7e5c0 100644 --- a/src/Message/AuthorizeRequest.php +++ b/src/Message/AuthorizeRequest.php @@ -241,14 +241,19 @@ public function sendData($data) $this->validate('userName', 'password'); $data['currency'] = $this->getCurrencyNumeric(); $data['amount'] = $this->getAmountInteger(); + $data = array_merge( + [ + 'userName' => $this->getUserName(), + 'password' => $this->getPassword(), + ], + $data + ); + $httpResponse = $this->httpClient->request( $this->getHttpMethod(), $url, $this->getHeaders(), - json_encode(array_merge([ - 'userName' => $this->getUserName(), - 'password' => $this->getPassword() - ], $data)) + http_build_query($data, '', '&') ); $responseClassName = str_replace('Request', 'Response', \get_class($this)); @@ -259,6 +264,8 @@ public function sendData($data) ); } - return $reflection->newInstance($this, json_decode($httpResponse->getBody(true), true)); + $content = json_decode($httpResponse->getBody()->getContents(), true); + + return $reflection->newInstance($this, $content); } }