1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-04 12:52:27 +08:00

fix some bugs (#277)

* fix payRequset xml marshal: root element should be xml

* support HMAC-SHA256 for unifiedorder api

* support HMAC-SHA256 for PaidVerifySign

* fix SignType is nil

* fix code style

* constantize SignType

* add comments

* fix code style
This commit is contained in:
huang wei
2020-06-14 23:23:58 +08:00
committed by GitHub
parent fe31f04640
commit c14c020a3c
6 changed files with 97 additions and 95 deletions

View File

@@ -85,8 +85,15 @@ func (notify *Notify) PaidVerifySign(notifyRes PaidResult) bool {
// STEP3, 在键值对的最后加上key=API_KEY
signStrings = signStrings + "key=" + notify.Key
// STEP4, 进行MD5签名并且将所有字符转为大写.
sign := util.MD5Sum(signStrings)
// STEP4, 根据SignType计算出签名
var signType string
if notifyRes.SignType != nil {
signType = *notifyRes.SignType
}
sign, err := util.CalculateSign(signStrings, signType, notify.Key)
if err != nil {
return false
}
if sign != *notifyRes.Sign {
return false
}