mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-13 09:12:27 +08:00
openid needed when pay with JSAPI
This commit is contained in:
@@ -86,8 +86,8 @@ 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)
|
||||||
tradeType := "JSAPI"
|
tradeType := "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=%s&key=%s"
|
template := "appid=%s&body=%s&mch_id=%s&nonce_str=%s¬ify_url=%s&openid=%s&out_trade_no=%s&spbill_create_ip=%s&total_fee=%s&trade_type=%s&key=%s"
|
||||||
str := fmt.Sprintf(template, pcf.AppID, p.Body, pcf.PayMchID, nonceStr, pcf.PayNotifyURL, p.OutTradeNo, p.CreateIP, p.TotalFee, tradeType, pcf.PayKey)
|
str := fmt.Sprintf(template, pcf.AppID, p.Body, pcf.PayMchID, nonceStr, pcf.PayNotifyURL, p.OpenID, p.OutTradeNo, p.CreateIP, p.TotalFee, tradeType, pcf.PayKey)
|
||||||
sign := util.Md5Sum(str)
|
sign := util.Md5Sum(str)
|
||||||
request := payRequest{
|
request := payRequest{
|
||||||
AppID: pcf.AppID,
|
AppID: pcf.AppID,
|
||||||
@@ -100,6 +100,7 @@ func (pcf *Pay) PrePayId(p *PayParams) (prePayID string, err error) {
|
|||||||
SpbillCreateIp: p.CreateIP,
|
SpbillCreateIp: p.CreateIP,
|
||||||
NotifyUrl: pcf.PayNotifyURL,
|
NotifyUrl: pcf.PayNotifyURL,
|
||||||
TradeType: tradeType,
|
TradeType: tradeType,
|
||||||
|
OpenID: p.OpenID,
|
||||||
}
|
}
|
||||||
rawRet, err := util.PostXML(payGateway, request)
|
rawRet, err := util.PostXML(payGateway, request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user