diff --git a/alipay/client.go b/alipay/client.go index ef8d26e7..05cc7a98 100644 --- a/alipay/client.go +++ b/alipay/client.go @@ -249,3 +249,8 @@ func (a *Client) encryptBizContent(originData string) (string, error) { } return base64.StdEncoding.EncodeToString(encryptData), nil } + +// SetHttpClient 设置自定义的xhttp.Client +func (a *Client) SetHttpClient(client *xhttp.Client) { + a.hc = client +} diff --git a/allinpay/client.go b/allinpay/client.go index 34672f6e..ff5bc9e7 100644 --- a/allinpay/client.go +++ b/allinpay/client.go @@ -136,3 +136,8 @@ func (c *Client) doPost(ctx context.Context, path string, bm gopay.BodyMap) (bs } return bs, nil } + +// SetHttpClient 设置自定义的xhttp.Client +func (c *Client) SetHttpClient(client *xhttp.Client) { + c.hc = client +} diff --git a/wechat/client.go b/wechat/client.go index 4cbce50c..15bc9bc5 100644 --- a/wechat/client.go +++ b/wechat/client.go @@ -58,6 +58,16 @@ func (w *Client) SetBodySize(sizeMB int) { } } +// SetHttpClient 设置自定义的xhttp.Client +func (w *Client) SetHttpClient(client *xhttp.Client) { + w.hc = client +} + +// SetTLSHttpClient 设置自定义的xhttp.Client +func (w *Client) SetTLSHttpClient(client *xhttp.Client) { + w.tlsHc = client +} + // 向微信发送Post请求,对于本库未提供的微信API,可自行实现,通过此方法发送请求 // bm:请求参数的BodyMap // path:接口地址去掉baseURL的path,例如:url为https://api.mch.weixin.qq.com/pay/micropay,只需传 pay/micropay diff --git a/wechat/v3/client.go b/wechat/v3/client.go index 358d2ec8..3d7424a8 100644 --- a/wechat/v3/client.go +++ b/wechat/v3/client.go @@ -85,3 +85,8 @@ func (c *ClientV3) SetBodySize(sizeMB int) { c.hc.SetBodySize(sizeMB) } } + +// SetHttpClient 设置自定义的xhttp.Client +func (c *ClientV3) SetHttpClient(client *xhttp.Client) { + c.hc = client +}