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

修改退款 bug 及增加付款到零钱的支付 (#373)

* fix refund bug and add transfer to wallet support

* fmt code

* fix golangci-lint

* fix golangci-lint
This commit is contained in:
baiyuxiong
2021-03-05 11:46:13 +08:00
committed by GitHub
parent 64c2de7ab4
commit ad3cc913b0
2 changed files with 149 additions and 2 deletions

View File

@@ -24,6 +24,7 @@ func NewRefund(cfg *config.Config) *Refund {
//Params 调用参数
type Params struct {
TransactionID string
OutTradeNo string
OutRefundNo string
TotalFee string
RefundFee string
@@ -39,7 +40,8 @@ type request struct {
NonceStr string `xml:"nonce_str"`
Sign string `xml:"sign"`
SignType string `xml:"sign_type,omitempty"`
TransactionID string `xml:"transaction_id"`
TransactionID string `xml:"transaction_id,omitempty"`
OutTradeNo string `xml:"out_trade_no,omitempty"`
OutRefundNo string `xml:"out_refund_no"`
TotalFee string `xml:"total_fee"`
RefundFee string `xml:"refund_fee"`
@@ -83,7 +85,12 @@ func (refund *Refund) Refund(p *Params) (rsp Response, err error) {
param["refund_fee"] = p.RefundFee
param["total_fee"] = p.TotalFee
param["sign_type"] = util.SignTypeMD5
param["transaction_id"] = p.TransactionID
if p.TransactionID != "" {
param["transaction_id"] = p.TransactionID
}
if p.OutTradeNo != "" {
param["out_trade_no"] = p.OutTradeNo
}
if p.NotifyURL != "" {
param["notify_url"] = p.NotifyURL
}
@@ -101,9 +108,11 @@ func (refund *Refund) Refund(p *Params) (rsp Response, err error) {
SignType: util.SignTypeMD5,
TransactionID: p.TransactionID,
OutRefundNo: p.OutRefundNo,
OutTradeNo: p.OutTradeNo,
TotalFee: p.TotalFee,
RefundFee: p.RefundFee,
RefundDesc: p.RefundDesc,
NotifyURL: p.NotifyURL,
}
rawRet, err := util.PostXMLWithTLS(refundGateway, req, p.RootCa, refund.MchID)
if err != nil {