Client main functions: to send invitation code to the user, access to payment information is sent to the platform, to generate two-dimensional code collection
Send an invitation code to the user
private void Client_ReceiveMessage(object sender, MessageWXEventArgs e) { IF (e.Content == " invitation code " || e.Content == " binding " ) { Task.Run(()=> { ManageAPI manageapi = new ManageAPI(); string code= manageapi.AddWexinUser(e.Sender, e.SenderNick, ""); if(!string.IsNullOrEmpty(code)) client.SendMessage(e.FromId, code); }); } }
Client gets an invitation code from the platform
public string AddWexinUser(string weixinid, string weixinnick,string headpic) { try { string t = GetTime(DateTime.Now).ToString(); Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("weixinid", weixinid); dic.Add("weixinnick", weixinnick); dic.Add("t", t); dic.Add("password", password); HttpItem item = new HttpItem(); item.URL = serverurl; item.Method = "POST"; item.PostEncoding = Encoding.UTF8; item.Postdata = ParamEncrypt.ParamToString(dic); HttpHelper http = new HttpHelper(); HttpResult result = http.GetHtml(item); JavaScriptSerializer js = new JavaScriptSerializer(); dynamic modelDy = js.Deserialize<dynamic>(result.Html); if (modelDy["code"] == 0) return modelDy["msg"]; } catch { } return ""; }
Submit billing information to the platform
public UserCallbackModel Bill(string weixinid, string weixinnick, decimal amount, string memo, string payermemo, string tradeno, string paytype) { try { string t = GetTime(DateTime.Now).ToString(); Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("weixinid", weixinid); dic.Add("weixinnick", weixinnick); dic.Add("amount", amount.ToString()); dic.Add("memo", memo); dic.Add("payermemo", payermemo); dic.Add("tradeno", tradeno); dic.Add("paytype", paytype); dic.Add("t", t); dic.Add("password", password); HttpItem item = new HttpItem(); item.URL =serverurlbill; item.Method = "POST"; item.PostEncoding = Encoding.UTF8; item.Postdata = ParamEncrypt.ParamToString(dic); HttpHelper http = new HttpHelper(); HttpResult result = http.GetHtml(item); JavaScriptSerializer js = new JavaScriptSerializer(); dynamic modelDy = js.Deserialize<dynamic>(result.Html); if (modelDy["code"] == 0) { UserCallbackModel userCallback = new UserCallbackModel(); userCallback.amount = amount; userCallback.memo = memo; userCallback.password = modelDy["data"]["password"]; userCallback.payermemo = payermemo; userCallback.paytype = paytype; userCallback.tradeno = tradeno; userCallback.url = modelDy["data"]["url"]; userCallback.weixinid = weixinid; userCallback.weixinnick = weixinnick; return userCallback; } } catch { } return null; }
QR code to submit payment platform
public void UpdateQRcode(int id,string qrcode) { try { string t = GetTime(DateTime.Now).ToString(); Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("id", id.ToString()); dic.Add("qrcode", qrcode); dic.Add("t", t); dic.Add("password", password); HttpItem item = new HttpItem(); item.URL =serverqrcodeurl; item.Method = "POST"; item.PostEncoding = Encoding.UTF8; item.Postdata = ParamEncrypt.ParamToString(dic); HttpHelper http = new HttpHelper(); HttpResult result = http.GetHtml(item); } catch { } }
Basic functions such client is realized, of course, some other features not described in detail here
Any suggestions or have common interests can communicate with each other
QQ:693999261