|
|
@ -8,12 +8,10 @@ import ( |
|
|
|
"reflect" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"git.tetele.net/tgo/network" |
|
|
|
|
|
|
|
"git.tetele.net/tgo/helper" |
|
|
|
) |
|
|
|
|
|
|
|
//请求支付
|
|
|
|
// 请求支付
|
|
|
|
type PayXml struct { |
|
|
|
XMLName xml.Name `xml:"xml"` |
|
|
|
Appid string `xml:"appid"` |
|
|
@ -28,7 +26,7 @@ type PayXml struct { |
|
|
|
AuthCode string `xml:"auth_code"` |
|
|
|
} |
|
|
|
|
|
|
|
//支付结果
|
|
|
|
// 支付结果
|
|
|
|
type PayReturnXml struct { |
|
|
|
ReturnCode string `xml:"return_code"` |
|
|
|
ReturnMsg string `xml:"return_msg"` |
|
|
@ -57,7 +55,7 @@ type PayReturnXml struct { |
|
|
|
PromotionDetail string `xml:"promotion_detail"` |
|
|
|
} |
|
|
|
|
|
|
|
//查询支付
|
|
|
|
// 查询支付
|
|
|
|
type QueryXml struct { |
|
|
|
XMLName xml.Name `xml:"xml"` |
|
|
|
Appid string `xml:"appid"` |
|
|
@ -67,7 +65,7 @@ type QueryXml struct { |
|
|
|
Sign string `xml:"sign"` |
|
|
|
} |
|
|
|
|
|
|
|
//查询结果
|
|
|
|
// 查询结果
|
|
|
|
type QueryReturnXml struct { |
|
|
|
ReturnCode string `xml:"return_code"` |
|
|
|
ReturnMsg string `xml:"return_msg"` |
|
|
@ -108,7 +106,7 @@ type ReverseXml struct { |
|
|
|
Sign string `xml:"sign"` |
|
|
|
} |
|
|
|
|
|
|
|
//撤消结果
|
|
|
|
// 撤消结果
|
|
|
|
type ReverseReturnXml struct { |
|
|
|
ReturnCode string `xml:"return_code"` |
|
|
|
ReturnMsg string `xml:"return_msg"` |
|
|
@ -147,7 +145,7 @@ func MicroPay(appid, mchid, mch_key, device_info, body, out_trade_no, auth_code, |
|
|
|
requestxml.Body = body |
|
|
|
requestxml.OutTradeNo = out_trade_no |
|
|
|
requestxml.TotalFee = helper.ToInt(helper.FloatMul(total_fee, 100)) |
|
|
|
requestxml.SpbillCreateIp = network.GetLocalIp() |
|
|
|
requestxml.SpbillCreateIp = GetLocalIp() |
|
|
|
requestxml.AuthCode = auth_code |
|
|
|
|
|
|
|
signStr := helper.StringJoin("appid=", requestxml.Appid, "&auth_code=", requestxml.AuthCode, |
|
|
@ -165,7 +163,7 @@ func MicroPay(appid, mchid, mch_key, device_info, body, out_trade_no, auth_code, |
|
|
|
log.Println(requestxml, string(reqXmlJson), err) |
|
|
|
|
|
|
|
url := "https://api.mch.weixin.qq.com/pay/micropay" |
|
|
|
ret, err := network.SendXml("POST", url, requestxml) |
|
|
|
ret, err := SendXml("POST", url, requestxml) |
|
|
|
|
|
|
|
log.Println("wechat micropay pay result:", string(ret), err) |
|
|
|
|
|
|
@ -222,7 +220,7 @@ func MicroPayQuery(appid, mchid, out_trade_no, mch_key string) (QueryReturnXml, |
|
|
|
requestxml.Sign = strings.ToUpper(signMd5) |
|
|
|
|
|
|
|
url := "https://api.mch.weixin.qq.com/pay/orderquery" |
|
|
|
ret, err := network.SendXml("POST", url, requestxml) |
|
|
|
ret, err := SendXml("POST", url, requestxml) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
log.Println("Err:", err) |
|
|
@ -280,7 +278,7 @@ func MicroPayReverse(appid, mchid, out_trade_no, mch_key string) (ReverseReturnX |
|
|
|
requestxml.Sign = strings.ToUpper(signMd5) |
|
|
|
|
|
|
|
url := "https://api.mch.weixin.qq.com/secapi/pay/reverse" |
|
|
|
ret, err := network.SendXml("POST", url, requestxml) |
|
|
|
ret, err := SendXml("POST", url, requestxml) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
log.Println("Err:", err) |
|
|
|