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

fix parameter trade_type

This commit is contained in:
Mongo
2017-10-30 21:55:48 +08:00
parent 016a9a58d9
commit d199cc947b

View File

@@ -88,7 +88,7 @@ func NewPay(ctx *context.Context) *Pay {
func (pcf *Pay) PrePayId(p *PayParams) (prePayID string, err error) {
nonceStr := util.RandomStr(32)
pType := "JSAPI"
template := "appid=%s&body=%s&mch_id=%s&nonce_str=%s&notify_url=%s&out_trade_no=%s&spbill_create_ip=%s&total_fee=%s&trade_type"
template := "appid=%s&body=%s&mch_id=%s&nonce_str=%s&notify_url=%s&out_trade_no=%s&spbill_create_ip=%s&total_fee=%s&trade_type=%s"
str := fmt.Sprintf(template, pcf.AppID, p.Body, pcf.PayMchID, nonceStr, pcf.PayNotifyURL, p.OutTradeNo, p.CreateIP, p.TotalFee, pType)
str += pcf.PayKey
sum := md5.Sum([]byte(str))
@@ -108,7 +108,7 @@ func (pcf *Pay) PrePayId(p *PayParams) (prePayID string, err error) {
}
rawRet, err := util.PostXML(payGateway, request)
if err != nil {
return "", err
return "", errors.New(err.Error() + " parameters : " + str)
}
payRet := payResult{}
err = xml.Unmarshal(rawRet, &payRet)