From 5e155e8e4504163713d3af0d9519861edaeb1926 Mon Sep 17 00:00:00 2001 From: jiangyong27 Date: Mon, 4 Nov 2024 14:41:07 +0800 Subject: [PATCH] refund fee --- unify/pay.go | 6 +++--- unify/pay_type.go | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/unify/pay.go b/unify/pay.go index 4a126f4..2ab8219 100644 --- a/unify/pay.go +++ b/unify/pay.go @@ -151,12 +151,12 @@ func (p *Pay) GetPartnerOrder(outTradeNo string) (map[string]interface{}, error) return rsp.Data, nil } -func (p *Pay) RefundOrder(outTradeNo, reason string) error { - if outTradeNo == "" { +func (p *Pay) RefundOrder(req *RefundPartnerOrderReq) error { + if req.OutTradeNo == "" { errors.New("outTradeNo is nil") } - reqUrl := fmt.Sprintf("%s/api/pay/order?outTradeNo=%s&reason=%s", p.address, outTradeNo, reason) + reqUrl := fmt.Sprintf("%s/api/pay/order?outTradeNo=%s&reason=%s&refundFee=%d", p.address, req.OutTradeNo, req.Reason, req.RefundFee) result, err := util.HttpDelete(reqUrl, map[string]string{ "x-token": p.token, }) diff --git a/unify/pay_type.go b/unify/pay_type.go index 1b8905e..a19af6d 100644 --- a/unify/pay_type.go +++ b/unify/pay_type.go @@ -44,6 +44,12 @@ type CreatePartnerOrderReq struct { Extra interface{} `json:"extra"` } +type RefundPartnerOrderReq struct { + OutTradeNo string `json:"outTradeNo"` + Reason string `json:"reason,omitempty"` + RefundFee int64 `json:"refundFee,omitempty"` +} + type CommonResponse struct { Code int `json:"code"` Message string `json:"message"`