From 15b91c7c559b2837381f0006a725bb7d4911ddf5 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 16 Nov 2023 16:33:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- md/alipay.go | 32 ++++++++++++++++++++++++++++++++ pay/alipay.go | 24 ++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/md/alipay.go b/md/alipay.go index 01dff9f..16d0539 100644 --- a/md/alipay.go +++ b/md/alipay.go @@ -167,3 +167,35 @@ type AlipayTradePay struct { } `json:"alipay_trade_pay_response"` Sign string `json:"sign"` } + +type AlipayTradeRefund struct { + AlipayTradeRefundResponse struct { + Code string `json:"code"` + Msg string `json:"msg"` + TradeNo string `json:"trade_no"` + OutTradeNo string `json:"out_trade_no"` + BuyerLogonId string `json:"buyer_logon_id"` + FundChange string `json:"fund_change"` + RefundFee float64 `json:"refund_fee"` + RefundDetailItemList []struct { + FundChannel string `json:"fund_channel"` + Amount int `json:"amount"` + RealAmount float64 `json:"real_amount"` + FundType string `json:"fund_type"` + } `json:"refund_detail_item_list"` + StoreName string `json:"store_name"` + BuyerUserId string `json:"buyer_user_id"` + SendBackFee string `json:"send_back_fee"` + RefundHybAmount string `json:"refund_hyb_amount"` + RefundChargeInfoList []struct { + RefundChargeFee float64 `json:"refund_charge_fee"` + SwitchFeeRate string `json:"switch_fee_rate"` + ChargeType string `json:"charge_type"` + RefundSubFeeDetailList []struct { + RefundChargeFee float64 `json:"refund_charge_fee"` + SwitchFeeRate string `json:"switch_fee_rate"` + } `json:"refund_sub_fee_detail_list"` + } `json:"refund_charge_info_list"` + } `json:"alipay_trade_refund_response"` + Sign string `json:"sign"` +} diff --git a/pay/alipay.go b/pay/alipay.go index de70fe1..f44b7d4 100644 --- a/pay/alipay.go +++ b/pay/alipay.go @@ -415,3 +415,27 @@ func checkPublicParam(a *alipay.Client, bm gopay.BodyMap) { bm.Set("auth_token", a.AuthToken) } } + +//原路退回 +func AlipayTradeRefund(args map[string]string) (*md.AlipayTradeRefund, error) { + client := Comm(args) + if client == nil { + return nil, errors.New("获取失败") + } + //请求参数 + bm := make(gopay.BodyMap) + bm.SetBodyMap("biz_content", func(bz gopay.BodyMap) { + bz.Set("out_trade_no", args["out_trade_no"]) + bz.Set("refund_amount", args["refund_amount"]) + bz.Set("refund_reason", args["refund_reason"]) + bz.Set("out_request_no", args["out_request_no"]) + }) + var aliPsp md.AlipayTradeRefund + v2, err := PostAliPayAPISelfV2(client, bm, "alipay.trade.refund", &aliPsp) + if err != nil { + xlog.Error(err) + return nil, err + } + res := v2.(*md.AlipayTradeRefund) + return res, nil +}