Skip to content

Commit

Permalink
修复微信支付缺少notify_url的bug (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
wgjtyu authored Sep 8, 2021
1 parent 39ed108 commit 47adf42
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pay/order/pay.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ func (o *Order) BridgeAppConfig(p *Params) (cfg ConfigForApp, err error) {
// PrePayOrder return data for invoke wechat payment
func (o *Order) PrePayOrder(p *Params) (payOrder PreOrder, err error) {
nonceStr := util.RandomStr(32)

// 通知地址
if len(p.NotifyURL) == 0 {
p.NotifyURL = o.NotifyURL // 默认使用order.NotifyURL
}

param := map[string]string{
"appid": o.AppID,
"body": p.Body,
Expand All @@ -224,17 +230,13 @@ func (o *Order) PrePayOrder(p *Params) (payOrder PreOrder, err error) {
"detail": p.Detail,
"attach": p.Attach,
"goods_tag": p.GoodsTag,
"notify_url": p.NotifyURL,
}
// 签名类型
if param["sign_type"] == "" {
param["sign_type"] = util.SignTypeMD5
}

// 通知地址
if p.NotifyURL != "" {
param["notify_url"] = p.NotifyURL
}

if p.TimeExpire != "" {
// 如果有传入交易结束时间
param["time_expire"] = p.TimeExpire
Expand Down

0 comments on commit 47adf42

Please sign in to comment.