1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-08 06:32:27 +08:00

微信支付 - 退款通知 (#359)

* 🆕 发起退款 - 添加notify_url参数

* 🆕 退款通知
This commit is contained in:
LouGaZen
2021-02-07 09:49:43 +08:00
committed by GitHub
parent e5f0d5eab7
commit d5a67eaf29
4 changed files with 213 additions and 3 deletions

View File

@@ -29,6 +29,7 @@ type Params struct {
RefundFee string
RefundDesc string
RootCa string //ca证书
NotifyURL string
}
//request 接口请求参数
@@ -43,7 +44,7 @@ type request struct {
TotalFee string `xml:"total_fee"`
RefundFee string `xml:"refund_fee"`
RefundDesc string `xml:"refund_desc,omitempty"`
//NotifyUrl string `xml:"notify_url,omitempty"`
NotifyURL string `xml:"notify_url,omitempty"`
}
//Response 接口返回
@@ -83,13 +84,16 @@ func (refund *Refund) Refund(p *Params) (rsp Response, err error) {
param["total_fee"] = p.TotalFee
param["sign_type"] = util.SignTypeMD5
param["transaction_id"] = p.TransactionID
if p.NotifyURL != "" {
param["notify_url"] = p.NotifyURL
}
sign, err := util.ParamSign(param, refund.Key)
if err != nil {
return
}
request := request{
req := request{
AppID: refund.AppID,
MchID: refund.MchID,
NonceStr: nonceStr,
@@ -101,7 +105,7 @@ func (refund *Refund) Refund(p *Params) (rsp Response, err error) {
RefundFee: p.RefundFee,
RefundDesc: p.RefundDesc,
}
rawRet, err := util.PostXMLWithTLS(refundGateway, request, p.RootCa, refund.MchID)
rawRet, err := util.PostXMLWithTLS(refundGateway, req, p.RootCa, refund.MchID)
if err != nil {
return
}