From 37c6bec7c6ca78fcec71ad55666fbc5bd75dca4a Mon Sep 17 00:00:00 2001 From: Dmitriy Larionov Date: Tue, 16 Oct 2018 11:23:51 +0500 Subject: [PATCH 1/3] Update AbstractRequest.php --- src/Message/AbstractRequest.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index aa85c1d..ddfb6b2 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); } /** From 19c51e9baa653db7dd27ab815e91ff1b115e98b1 Mon Sep 17 00:00:00 2001 From: Dmitriy Larionov Date: Tue, 16 Oct 2018 11:25:38 +0500 Subject: [PATCH 2/3] Update AuthorizeRequest.php --- src/Message/AuthorizeRequest.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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); } } From 529b17840f252cb4ac3341ab7b2e97cbf0e3a134 Mon Sep 17 00:00:00 2001 From: Dmitriy Larionov Date: Tue, 16 Oct 2018 11:27:11 +0500 Subject: [PATCH 3/3] Update AbstractRequest.php --- src/Message/AbstractRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index ddfb6b2..a1f4283 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -163,7 +163,7 @@ public function sendData($data) ], $data ); - + $httpResponse = $this->httpClient->request( $this->getHttpMethod(), $url,