Skip to content

Commit

Permalink
Fix request body content-type
Browse files Browse the repository at this point in the history
  • Loading branch information
GizemSever committed Sep 21, 2022
1 parent 47046a1 commit 0d7e9cc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
8 changes: 7 additions & 1 deletion src/PaytrClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0d7e9cc

Please sign in to comment.