diff --git a/plugins/union_pay/internal/po/po.go b/plugins/union_pay/internal/po/po.go index 306dcf0..bf4ad6d 100644 --- a/plugins/union_pay/internal/po/po.go +++ b/plugins/union_pay/internal/po/po.go @@ -69,8 +69,6 @@ func (req *Notify) GetReId() string { } func (req *Notify) ToJson() []byte { - //kvRows := utils.SortStruct(req.Body) - //b, _ := json.Marshal(kvRows) b, _ := json.Marshal(req.Body) return b } diff --git a/plugins/union_pay/internal/util.go b/plugins/union_pay/internal/util.go index 2104b75..fa63dd7 100644 --- a/plugins/union_pay/internal/util.go +++ b/plugins/union_pay/internal/util.go @@ -26,8 +26,8 @@ func headers(config *Config, req po.Req, bizMethod string) map[string][]string { milliseconds := now.Unix()*1000 + int64(now.Nanosecond())/1e6 h.Add("reqTs", fmt.Sprintf("%d", milliseconds)) - encodedHash := utils.Sha(vo.Version, config.Config.AppId, bizMethod, req.GetReId(), string(req.ToJson())) - signValue, err := utils.Sign(encodedHash, utils.FormatPEMPrivateKey(config.Extra.RsaPrk)) + rehash := utils.Sha(vo.Version, config.Config.AppId, bizMethod, req.GetReId(), string(req.ToJson())) + signValue, err := utils.Sign(rehash, utils.FormatPEMPrivateKey(config.Extra.RsaPrk)) if err != nil { return nil } @@ -45,8 +45,8 @@ func verify(config *Config, req *po.Notify, notifyBizMethod string) error { if req.Headers.BizMethod != notifyBizMethod { return fmt.Errorf("业务方法不匹配") } - encodedHash := utils.Sha(req.Headers.Version, config.Config.AppId, req.Headers.BizMethod, req.GetReId(), string(req.ToJson())) - lowerStr := strings.ToLower(encodedHash) + rehash := utils.Sha(req.Headers.Version, config.Config.AppId, req.Headers.BizMethod, req.GetReId(), string(req.ToJson())) + lowerStr := strings.ToLower(rehash) if utils.Verify(lowerStr, req.Headers.Sign, utils.FormatPEMPrivateKey(config.Extra.RsaNpk)) { return nil }