diff --git a/lib/local_wechat/api.go b/lib/local_wechat/api.go index 4654f7b..53814e3 100644 --- a/lib/local_wechat/api.go +++ b/lib/local_wechat/api.go @@ -99,6 +99,23 @@ func TradeShowQuery(client *wechat.Client, transactionId string) (*wechat.QueryO return wxRsp, resBm, nil } +func TradeShowRefundQuery(client *wechat.Client, transactionId string) (*wechat.QueryRefundResponse, gopay.BodyMap, error) { + // 初始化 BodyMap + bm := make(gopay.BodyMap) + bm.Set("transaction_id", transactionId). + Set("nonce_str", util.GetRandomString(32)). + Set("sign_type", wechat.SignType_MD5) + wxRsp, resBm, err := client.QueryRefund(bm) + fmt.Println(wxRsp) + fmt.Println(resBm) + if err != nil { + xlog.Error(err) + fmt.Println(err) + return wxRsp, resBm, err + } + return wxRsp, resBm, nil +} + // TradeAppPay is 微信APP支付 func TradeAppPay(client *wechat.Client, subject, orderID, amount, notifyUrl string) (map[string]string, error) { // 初始化 BodyMap diff --git a/pay/pay_by_own.go b/pay/pay_by_own.go index 03e9f41..fa0b790 100644 --- a/pay/pay_by_own.go +++ b/pay/pay_by_own.go @@ -152,3 +152,8 @@ func WxShowQuery(params map[string]string) (*wechat.QueryOrderResponse, gopay.Bo r, r1, err := local_wxpay.TradeShowQuery(client, params["transaction_id"]) return r, r1, err } +func TradeShowRefundQuery(params map[string]string) (*wechat.QueryRefundResponse, gopay.BodyMap, error) { + client := local_wxpay.NewClient(params["pay_wx_appid"], params["pay_wx_mch_id"], params["pay_wx_api_key"], true) + r, r1, err := local_wxpay.TradeShowRefundQuery(client, params["transaction_id"]) + return r, r1, err +}