query escape

This commit is contained in:
jiangyong27 2025-03-12 17:49:14 +08:00
parent 55aa6f3214
commit c3a37fafc9
1 changed files with 3 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"git.u8t.cn/open/gosdk/util" "git.u8t.cn/open/gosdk/util"
"net/url"
) )
var ( var (
@ -176,7 +177,7 @@ func (p *Pay) RefundOrder(req *RefundOrderReq) error {
errors.New("outTradeNo is nil") errors.New("outTradeNo is nil")
} }
reqUrl := fmt.Sprintf("%s/api/pay/order?outTradeNo=%s&reason=%s&refundFee=%d", p.address, req.OutTradeNo, req.Reason, req.RefundFee) reqUrl := fmt.Sprintf("%s/api/pay/order?outTradeNo=%s&reason=%s&refundFee=%d", p.address, req.OutTradeNo, url.QueryEscape(req.Reason), req.RefundFee)
result, err := util.HttpDelete(reqUrl, map[string]string{ result, err := util.HttpDelete(reqUrl, map[string]string{
"x-token": p.token, "x-token": p.token,
}) })
@ -200,7 +201,7 @@ func (p *Pay) RefundPartnerOrder(req *RefundOrderReq) error {
errors.New("outTradeNo is nil") errors.New("outTradeNo is nil")
} }
reqUrl := fmt.Sprintf("%s/api/pay/partner/order?outTradeNo=%s&reason=%s&refundFee=%d", p.address, req.OutTradeNo, req.Reason, req.RefundFee) reqUrl := fmt.Sprintf("%s/api/pay/partner/order?outTradeNo=%s&reason=%s&refundFee=%d", p.address, req.OutTradeNo, url.QueryEscape(req.Reason), req.RefundFee)
result, err := util.HttpDelete(reqUrl, map[string]string{ result, err := util.HttpDelete(reqUrl, map[string]string{
"x-token": p.token, "x-token": p.token,
}) })