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 +}