public static async Task <string> CorpPayAsync(int num) { var openid = "oO8Kd1bx8pPV6dGkOI7KILsrmPLY"; var f = (double)num / 100; if (openid != null) { JsApiPay jsApiPay = new JsApiPay(null); jsApiPay.openid = openid; jsApiPay.total_fee = num; //JSAPI支付预处理 try { WxPayData unifiedOrderResult = jsApiPay.GetCompanycParameters("提现"); //在页面上显示订单信息 var info = unifiedOrderResult.ToPrintStr(); //System.Net.Http.HttpClient http = new System.Net.Http.HttpClient(); var xml = unifiedOrderResult.ToXml(); //HttpContent hc = new StringContent(unifiedOrderResult.ToXml()); var str = HttpService.Post(unifiedOrderResult.ToXml(), "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers", true, 3); //var messageTask =await http.PostAsync("https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers", hc); JObject obj = new JObject(); //obj.Add("bill", uc.bill.ToString()); return(str);// await messageTask.Content.ReadAsStringAsync(); } catch (Exception ex) { return("下单失败"); } } return(null); }
public async Task <string> CorpPayAsync(int num) { var openid = HttpContext.Session.GetString("openid"); var uc = this.userc.read(openid); var f = (double)num / 100; if (uc.bill < f) { return("输入金额过大"); } uc.bill -= f; if (openid != null) { JsApiPay jsApiPay = new JsApiPay(this); jsApiPay.openid = openid; jsApiPay.total_fee = num; //JSAPI支付预处理 try { WxPayData unifiedOrderResult = jsApiPay.GetCompanycParameters("提现"); //在页面上显示订单信息 var info = unifiedOrderResult.ToPrintStr(); System.Net.Http.HttpClient http = new System.Net.Http.HttpClient(); HttpContent hc = new StringContent(unifiedOrderResult.ToXml()); var str = HttpService.Post(unifiedOrderResult.ToXml(), "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers", true, 3000); //var messageTask =await http.PostAsync("https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers", hc); JObject obj = new JObject(); obj.Add("bill", uc.bill.ToString()); var res = this.db.Execute(uiltT.Update(obj, "userinfo", "where id=" + uc.id)); return(str);// await messageTask.Content.ReadAsStringAsync(); } catch (Exception ex) { return("下单失败"); } } return(null); }