From 32d3fdbfc83a10637f8599816340e5e532ae59d4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 18 Mar 2020 20:02:03 +0800 Subject: [PATCH] 1 --- PayServer/src/base/platApi/qqApi.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/PayServer/src/base/platApi/qqApi.go b/PayServer/src/base/platApi/qqApi.go index ca50486..609caf2 100755 --- a/PayServer/src/base/platApi/qqApi.go +++ b/PayServer/src/base/platApi/qqApi.go @@ -49,6 +49,20 @@ type QQPrePayRes struct { PrepayId string `json:"prepayId"` } +type QQPrePayReq struct { + OpenId string `json:"openid"` + AppId string `json:"appid"` + Ts int `json:"ts"` + ZoneId string `json:"zone_id"` + Pf string `json:"pf"` + Amt int `json:"amt"` + GoodId string `json:"goodid"` + GoodNum string `json:"good_num"` + AppRemark string `json:"app_remark"` + BillNo string `json:"bill_no"` + Sig string `json:"sig"` +} + func QQPrePay(openid string, appid string, zone string, amt string, goodId string, goodNum uint32, token string, sessionKey string) (*QQPrePayRes, error) { u := "https://api.q.qq.com/api/json/openApiPay/GamePrePay?access_token=" + token value := url.Values{} @@ -70,7 +84,10 @@ func QQPrePay(openid string, appid string, zone string, amt string, goodId strin h.Write([]byte(param)) sign := hex.EncodeToString(h.Sum(nil)) value.Set("sig", sign) - data, _ := json.Marshal(util.UrlValuesToMap(value)) + req := &QQPrePayReq{}; + raw_data, _ := json.Marshal(util.UrlValuesToMap(value)) + err := json.Unmarshal(raw_data, &req) + data, _ := json.Marshal(req) resp, err := http.Post(u, "application/json;charset=UTF-8", bytes.NewReader(data)) if err != nil { log.Error("Post error ", err)