Skip to content

Commit

Permalink
支持with方式自定义header (#2516)
Browse files Browse the repository at this point in the history
```
$apiClient = EasyWeChat::pay()->getClient();
$apiClient->withHeader('Wechatpay-Serial', 'adfasdsadfa')->postJson('v3/transfer/batches', []);
```
  • Loading branch information
bangbangda authored Jun 28, 2022
1 parent 2e80b0e commit 85a4939
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Pay/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ public function request(string $method, string $url, array $options = []): Respo
$options['headers']['Content-Type'] = 'text/xml';/** @phpstan-ignore-line */
}
}

// 合并通过 withHeader 和 withHeaders 设置的信息
if (!empty($this->prependHeaders)) {
$options['headers'] = array_merge($this->prependHeaders, $options['headers'] ?? []);
}

return new Response($this->client->request($method, $url, $options), throw: $this->throw);
}
Expand Down

1 comment on commit 85a4939

@vercel
Copy link

@vercel vercel bot commented on 85a4939 Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

easywechat – ./

easywechat.vercel.app
easywechat-overtrue.vercel.app
easywechat-git-6x-overtrue.vercel.app

Please sign in to comment.