|
|
@@ -13,7 +13,7 @@ func TestWeChatClient_UnifiedOrder(t *testing.T) {
|
|
|
// mchID:商户ID
|
|
|
// secretKey:Key值
|
|
|
// isProd:是否是正式环境
|
|
|
- client := NewWeChatClient(appID, mchID, secretKey, true)
|
|
|
+ client := NewWeChatClient(appID, mchID, secretKey, false)
|
|
|
|
|
|
//初始化参数Map
|
|
|
body := make(BodyMap)
|
|
|
@@ -45,11 +45,11 @@ func TestWeChatClient_QueryOrder(t *testing.T) {
|
|
|
// mchID:商户ID
|
|
|
// secretKey:Key值
|
|
|
// isProd:是否是正式环境
|
|
|
- client := NewWeChatClient(appID, mchID, secretKey, true)
|
|
|
+ client := NewWeChatClient(appID, mchID, secretKey, false)
|
|
|
|
|
|
//初始化参数结构体
|
|
|
body := make(BodyMap)
|
|
|
- body.Set("out_trade_no", "Osgn3y181hYfFoGvn31MM61hk0mCCpYS")
|
|
|
+ body.Set("out_trade_no", "MfZC2segKxh0bnJSELbvKNeH3d9oWvvQ")
|
|
|
body.Set("nonce_str", GetRandomString(32))
|
|
|
body.Set("sign_type", SignType_MD5)
|
|
|
|
|
|
@@ -67,11 +67,11 @@ func TestWeChatClient_CloseOrder(t *testing.T) {
|
|
|
// mchID:商户ID
|
|
|
// secretKey:Key值
|
|
|
// isProd:是否是正式环境
|
|
|
- client := NewWeChatClient(appID, mchID, secretKey, true)
|
|
|
+ client := NewWeChatClient(appID, mchID, secretKey, false)
|
|
|
|
|
|
//初始化参数结构体
|
|
|
body := make(BodyMap)
|
|
|
- body.Set("out_trade_no", "Osgn3y181hYfFoGvn31MM61hk0mCCpYS")
|
|
|
+ body.Set("out_trade_no", "MfZC2segKxh0bnJSELbvKNeH3d9oWvvQ")
|
|
|
body.Set("nonce_str", GetRandomString(32))
|
|
|
body.Set("sign_type", SignType_MD5)
|
|
|
|
|
|
@@ -82,3 +82,122 @@ func TestWeChatClient_CloseOrder(t *testing.T) {
|
|
|
}
|
|
|
fmt.Println("Response:", wxRsp)
|
|
|
}
|
|
|
+
|
|
|
+func TestWeChatClient_Refund(t *testing.T) {
|
|
|
+ //初始化微信客户端
|
|
|
+ // appId:应用ID
|
|
|
+ // mchID:商户ID
|
|
|
+ // secretKey:Key值
|
|
|
+ // isProd:是否是正式环境
|
|
|
+ client := NewWeChatClient(appID, mchID, secretKey, false)
|
|
|
+
|
|
|
+ //初始化参数结构体
|
|
|
+ body := make(BodyMap)
|
|
|
+ body.Set("out_trade_no", "MfZC2segKxh0bnJSELbvKNeH3d9oWvvQ")
|
|
|
+ body.Set("nonce_str", GetRandomString(32))
|
|
|
+ body.Set("sign_type", SignType_MD5)
|
|
|
+ s := GetRandomString(64)
|
|
|
+ fmt.Println("s:", s)
|
|
|
+ body.Set("out_refund_no", s)
|
|
|
+ body.Set("total_fee", 101)
|
|
|
+ body.Set("refund_fee", 101)
|
|
|
+
|
|
|
+ //请求申请退款
|
|
|
+ wxRsp, err := client.Refund(body)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error:", err)
|
|
|
+ }
|
|
|
+ fmt.Println("Response:", wxRsp)
|
|
|
+}
|
|
|
+
|
|
|
+func TestWeChatClient_QueryRefund(t *testing.T) {
|
|
|
+ //初始化微信客户端
|
|
|
+ // appId:应用ID
|
|
|
+ // mchID:商户ID
|
|
|
+ // secretKey:Key值
|
|
|
+ // isProd:是否是正式环境
|
|
|
+ client := NewWeChatClient(appID, mchID, secretKey, false)
|
|
|
+
|
|
|
+ //初始化参数结构体
|
|
|
+ body := make(BodyMap)
|
|
|
+ body.Set("out_refund_no", "vk4264I1UQ3Hm3E4AKsavK8npylGSgQA092f9ckUxp8A2gXmnsLEdsupURVTcaC7")
|
|
|
+ body.Set("nonce_str", GetRandomString(32))
|
|
|
+ body.Set("sign_type", SignType_MD5)
|
|
|
+
|
|
|
+ //请求申请退款
|
|
|
+ wxRsp, err := client.QueryRefund(body)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error:", err)
|
|
|
+ }
|
|
|
+ fmt.Println("Response:", wxRsp)
|
|
|
+}
|
|
|
+
|
|
|
+func TestWeChatClient_DownloadBill(t *testing.T) {
|
|
|
+ //初始化微信客户端
|
|
|
+ // appId:应用ID
|
|
|
+ // mchID:商户ID
|
|
|
+ // secretKey:Key值
|
|
|
+ // isProd:是否是正式环境
|
|
|
+ client := NewWeChatClient(appID, mchID, secretKey, false)
|
|
|
+
|
|
|
+ //初始化参数结构体
|
|
|
+ body := make(BodyMap)
|
|
|
+ body.Set("nonce_str", GetRandomString(32))
|
|
|
+ body.Set("sign_type", SignType_MD5)
|
|
|
+ body.Set("bill_date", "20190122")
|
|
|
+ body.Set("bill_type", "ALL")
|
|
|
+
|
|
|
+ //请求订单查询,成功后得到结果
|
|
|
+ wxRsp, err := client.DownloadBill(body)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error:", err)
|
|
|
+ }
|
|
|
+ fmt.Println("Response:", wxRsp)
|
|
|
+}
|
|
|
+
|
|
|
+func TestWeChatClient_DownloadFundFlow(t *testing.T) {
|
|
|
+ //初始化微信客户端
|
|
|
+ // appId:应用ID
|
|
|
+ // mchID:商户ID
|
|
|
+ // secretKey:Key值
|
|
|
+ // isProd:是否是正式环境
|
|
|
+ client := NewWeChatClient(appID, mchID, secretKey, false)
|
|
|
+
|
|
|
+ //初始化参数结构体
|
|
|
+ body := make(BodyMap)
|
|
|
+ body.Set("nonce_str", GetRandomString(32))
|
|
|
+ body.Set("sign_type", SignType_HMAC_SHA256)
|
|
|
+ body.Set("bill_date", "20190122")
|
|
|
+ body.Set("account_type", "Basic")
|
|
|
+
|
|
|
+ //请求订单查询,成功后得到结果
|
|
|
+ wxRsp, err := client.DownloadFundFlow(body)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error:", err)
|
|
|
+ }
|
|
|
+ fmt.Println("Response:", wxRsp)
|
|
|
+}
|
|
|
+
|
|
|
+func TestWeChatClient_BatchQueryComment(t *testing.T) {
|
|
|
+ //初始化微信客户端
|
|
|
+ // appId:应用ID
|
|
|
+ // mchID:商户ID
|
|
|
+ // secretKey:Key值
|
|
|
+ // isProd:是否是正式环境
|
|
|
+ client := NewWeChatClient(appID, mchID, secretKey, false)
|
|
|
+
|
|
|
+ //初始化参数结构体
|
|
|
+ body := make(BodyMap)
|
|
|
+ body.Set("nonce_str", GetRandomString(32))
|
|
|
+ body.Set("sign_type", SignType_HMAC_SHA256)
|
|
|
+ body.Set("begin_time", "20190120000000")
|
|
|
+ body.Set("end_time", "20190122174000")
|
|
|
+ body.Set("offset", "0")
|
|
|
+
|
|
|
+ //请求订单查询,成功后得到结果
|
|
|
+ wxRsp, err := client.BatchQueryComment(body)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error:", err)
|
|
|
+ }
|
|
|
+ fmt.Println("Response:", wxRsp)
|
|
|
+}
|