Skip to content

Commit

Permalink
fix Wechatpay-Serial bug
Browse files Browse the repository at this point in the history
  • Loading branch information
iGoogle-ink committed Dec 13, 2021
1 parent 3f25b44 commit 707b168
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
5 changes: 2 additions & 3 deletions wechat/v3/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,9 @@ func (c *ClientV3) GetPlatformCerts() (certs *PlatformCertRsp, err error) {
return certs, nil
}

// Deprecated
// client 已内部集成证书获取并维护,无需再Set正式
// 设置 微信支付平台证书 和 证书序列号
// 注意:请预先通过 client.GetPlatformCerts() 获取 微信平台公钥证书 和 证书序列号
// 注意1:如已开启自动验签功能 client.AutoVerifySign(),无需再调用此方法设置
// 注意2:请预先通过 client.GetPlatformCerts() 获取 微信平台公钥证书 和 证书序列号
// 部分接口请求参数中敏感信息加密,使用此 微信支付平台公钥 和 证书序列号
func (c *ClientV3) SetPlatformCert(wxPublicKeyContent []byte, wxSerialNo string) (client *ClientV3) {
pubKey, err := xpem.DecodePublicKey(wxPublicKeyContent)
Expand Down
14 changes: 7 additions & 7 deletions wechat/v3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (c *ClientV3) doProdPostWithHeader(ctx context.Context, headerMap map[strin
}
httpClient.Header.Add(HeaderAuthorization, authorization)
httpClient.Header.Add(HeaderRequestID, fmt.Sprintf("%s-%d", util.GetRandomString(21), time.Now().Unix()))
httpClient.Header.Add(HeaderSerial, c.SerialNo)
httpClient.Header.Add(HeaderSerial, c.WxSerialNo)
httpClient.Header.Add("Accept", "*/*")
res, bs, err = httpClient.Type(xhttp.TypeJSON).Post(url).SendBodyMap(bm).EndBytes(ctx)
if err != nil {
Expand Down Expand Up @@ -110,7 +110,7 @@ func (c *ClientV3) doProdPost(ctx context.Context, bm gopay.BodyMap, path, autho
}
httpClient.Header.Add(HeaderAuthorization, authorization)
httpClient.Header.Add(HeaderRequestID, fmt.Sprintf("%s-%d", util.GetRandomString(21), time.Now().Unix()))
httpClient.Header.Add(HeaderSerial, c.SerialNo)
httpClient.Header.Add(HeaderSerial, c.WxSerialNo)
httpClient.Header.Add("Accept", "*/*")
res, bs, err = httpClient.Type(xhttp.TypeJSON).Post(url).SendBodyMap(bm).EndBytes(ctx)
if err != nil {
Expand Down Expand Up @@ -140,7 +140,7 @@ func (c *ClientV3) doProdGet(ctx context.Context, uri, authorization string) (re
}
httpClient.Header.Add(HeaderAuthorization, authorization)
httpClient.Header.Add(HeaderRequestID, fmt.Sprintf("%s-%d", util.GetRandomString(21), time.Now().Unix()))
httpClient.Header.Add(HeaderSerial, c.SerialNo)
httpClient.Header.Add(HeaderSerial, c.WxSerialNo)
httpClient.Header.Add("Accept", "*/*")
res, bs, err = httpClient.Type(xhttp.TypeJSON).Get(url).EndBytes(ctx)
if err != nil {
Expand Down Expand Up @@ -170,7 +170,7 @@ func (c *ClientV3) doProdPut(ctx context.Context, bm gopay.BodyMap, path, author
}
httpClient.Header.Add(HeaderAuthorization, authorization)
httpClient.Header.Add(HeaderRequestID, fmt.Sprintf("%s-%d", util.GetRandomString(21), time.Now().Unix()))
httpClient.Header.Add(HeaderSerial, c.SerialNo)
httpClient.Header.Add(HeaderSerial, c.WxSerialNo)
httpClient.Header.Add("Accept", "*/*")
res, bs, err = httpClient.Type(xhttp.TypeJSON).Put(url).SendBodyMap(bm).EndBytes(ctx)
if err != nil {
Expand Down Expand Up @@ -200,7 +200,7 @@ func (c *ClientV3) doProdDelete(ctx context.Context, bm gopay.BodyMap, path, aut
}
httpClient.Header.Add(HeaderAuthorization, authorization)
httpClient.Header.Add(HeaderRequestID, fmt.Sprintf("%s-%d", util.GetRandomString(21), time.Now().Unix()))
httpClient.Header.Add(HeaderSerial, c.SerialNo)
httpClient.Header.Add(HeaderSerial, c.WxSerialNo)
httpClient.Header.Add("Accept", "*/*")
res, bs, err = httpClient.Type(xhttp.TypeJSON).Delete(url).SendBodyMap(bm).EndBytes(ctx)
if err != nil {
Expand Down Expand Up @@ -230,7 +230,7 @@ func (c *ClientV3) doProdPostFile(ctx context.Context, bm gopay.BodyMap, path, a
}
httpClient.Header.Add(HeaderAuthorization, authorization)
httpClient.Header.Add(HeaderRequestID, fmt.Sprintf("%s-%d", util.GetRandomString(21), time.Now().Unix()))
httpClient.Header.Add(HeaderSerial, c.SerialNo)
httpClient.Header.Add(HeaderSerial, c.WxSerialNo)
httpClient.Header.Add("Accept", "*/*")
res, bs, err = httpClient.Type(xhttp.TypeMultipartFormData).Post(url).SendMultipartBodyMap(bm).EndBytes(ctx)
if err != nil {
Expand Down Expand Up @@ -260,7 +260,7 @@ func (c *ClientV3) doProdPatch(ctx context.Context, bm gopay.BodyMap, path, auth
}
httpClient.Header.Add(HeaderAuthorization, authorization)
httpClient.Header.Add(HeaderRequestID, fmt.Sprintf("%s-%d", util.GetRandomString(21), time.Now().Unix()))
httpClient.Header.Add(HeaderSerial, c.SerialNo)
httpClient.Header.Add(HeaderSerial, c.WxSerialNo)
httpClient.Header.Add("Accept", "*/*")
res, bs, err = httpClient.Type(xhttp.TypeJSON).Patch(url).SendBodyMap(bm).EndBytes(ctx)
if err != nil {
Expand Down

0 comments on commit 707b168

Please sign in to comment.