huangjiajun 11 mesi fa
parent
commit
15b91c7c55
2 ha cambiato i file con 56 aggiunte e 0 eliminazioni
  1. +32
    -0
      md/alipay.go
  2. +24
    -0
      pay/alipay.go

+ 32
- 0
md/alipay.go Vedi File

@@ -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"`
}

+ 24
- 0
pay/alipay.go Vedi File

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

Caricamento…
Annulla
Salva