This commit is contained in:
aozhiwei 2020-03-18 20:02:03 +08:00
parent 0e5d663cc5
commit 32d3fdbfc8

View File

@ -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)