mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-13 09:12:27 +08:00
fix parameter trade_type
This commit is contained in:
@@ -88,7 +88,7 @@ func NewPay(ctx *context.Context) *Pay {
|
|||||||
func (pcf *Pay) PrePayId(p *PayParams) (prePayID string, err error) {
|
func (pcf *Pay) PrePayId(p *PayParams) (prePayID string, err error) {
|
||||||
nonceStr := util.RandomStr(32)
|
nonceStr := util.RandomStr(32)
|
||||||
pType := "JSAPI"
|
pType := "JSAPI"
|
||||||
template := "appid=%s&body=%s&mch_id=%s&nonce_str=%s¬ify_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¬ify_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 := fmt.Sprintf(template, pcf.AppID, p.Body, pcf.PayMchID, nonceStr, pcf.PayNotifyURL, p.OutTradeNo, p.CreateIP, p.TotalFee, pType)
|
||||||
str += pcf.PayKey
|
str += pcf.PayKey
|
||||||
sum := md5.Sum([]byte(str))
|
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)
|
rawRet, err := util.PostXML(payGateway, request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", errors.New(err.Error() + " parameters : " + str)
|
||||||
}
|
}
|
||||||
payRet := payResult{}
|
payRet := payResult{}
|
||||||
err = xml.Unmarshal(rawRet, &payRet)
|
err = xml.Unmarshal(rawRet, &payRet)
|
||||||
|
|||||||
Reference in New Issue
Block a user