From 0d7e9cc3f44f0a4e5c682e47d93037eaf8d7f8b2 Mon Sep 17 00:00:00 2001 From: gizemsever Date: Wed, 21 Sep 2022 12:42:26 +0300 Subject: [PATCH] Fix request body content-type --- composer.json | 1 + src/PaytrClient.php | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 44c6d05..dc9657a 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "require": { "php": "^8.0|^8.1", "guzzlehttp/guzzle": "^7.0.1", + "illuminate/collections": "8.36", "illuminate/support": "^8.0|^9.0" }, "autoload": { diff --git a/src/PaytrClient.php b/src/PaytrClient.php index 6ab7e23..135580f 100644 --- a/src/PaytrClient.php +++ b/src/PaytrClient.php @@ -41,7 +41,13 @@ protected function callApi(string $method, string $url, $params = null, $headers $options['headers'] = $headers; } if ($params) { - $options['form_params'] = $params; + $requestParams = collect(array_keys($params)); + $options['multipart'] = $requestParams->map(function ($key) use ($params) { + return [ + 'name' => $key, + 'contents' => $params[$key] + ]; + })->toArray(); } $options['timeout'] = $this->options['timeout']; return $this->client->request($method, $this->options['base_uri'] . '/' . $url, $options);