Jerry %!s(int64=7) %!d(string=hai) anos
pai
achega
366956f69d
Modificáronse 1 ficheiros con 28 adicións e 6 borrados
  1. 28 6
      wechat_client_test.go

+ 28 - 6
wechat_client_test.go

@@ -29,7 +29,7 @@ func TestWeChatClient_UnifiedOrder(t *testing.T) {
 	//body.Set("device_info", "WEB")
 	//body.Set("device_info", "WEB")
 	body.Set("sign_type", SignType_MD5)
 	body.Set("sign_type", SignType_MD5)
 	//body.Set("scene_info", `{"h5_info": {"type":"Wap","wap_url": "http://www.igoogle.ink","wap_name": "测试支付"}}`)
 	//body.Set("scene_info", `{"h5_info": {"type":"Wap","wap_url": "http://www.igoogle.ink","wap_name": "测试支付"}}`)
-	//body.Set("openid", openID)
+	body.Set("openid", openID)
 
 
 	//请求支付下单,成功后得到结果
 	//请求支付下单,成功后得到结果
 	wxRsp, err := client.UnifiedOrder(body)
 	wxRsp, err := client.UnifiedOrder(body)
@@ -48,13 +48,35 @@ func TestWeChatClient_QueryOrder(t *testing.T) {
 	client := NewWeChatClient(appID, mchID, secretKey, true)
 	client := NewWeChatClient(appID, mchID, secretKey, true)
 
 
 	//初始化参数结构体
 	//初始化参数结构体
-	params := make(BodyMap)
-	params.Set("out_trade_no", "CC68aTofMIwVKkVR5UruoBLFFXTAqBfv")
-	params.Set("nonce_str", GetRandomString(32))
-	params.Set("sign_type", SignType_MD5)
+	body := make(BodyMap)
+	body.Set("out_trade_no", "Osgn3y181hYfFoGvn31MM61hk0mCCpYS")
+	body.Set("nonce_str", GetRandomString(32))
+	body.Set("sign_type", SignType_MD5)
+
+	//请求订单查询,成功后得到结果
+	wxRsp, err := client.QueryOrder(body)
+	if err != nil {
+		fmt.Println("Error:", err)
+	}
+	fmt.Println("Response:", wxRsp)
+}
+
+func TestWeChatClient_CloseOrder(t *testing.T) {
+	//初始化微信客户端
+	//    appId:应用ID
+	//    mchID:商户ID
+	//    secretKey:Key值
+	//    isProd:是否是正式环境
+	client := NewWeChatClient(appID, mchID, secretKey, true)
+
+	//初始化参数结构体
+	body := make(BodyMap)
+	body.Set("out_trade_no", "Osgn3y181hYfFoGvn31MM61hk0mCCpYS")
+	body.Set("nonce_str", GetRandomString(32))
+	body.Set("sign_type", SignType_MD5)
 
 
 	//请求订单查询,成功后得到结果
 	//请求订单查询,成功后得到结果
-	wxRsp, err := client.QueryOrder(params)
+	wxRsp, err := client.CloseOrder(body)
 	if err != nil {
 	if err != nil {
 		fmt.Println("Error:", err)
 		fmt.Println("Error:", err)
 	}
 	}