/// <summary> /// 统一下单接口 /// </summary> /// <param name="request"></param> /// <param name="response"></param> public void CreateOrders(CreateOrder request, CreateOrderResponse response) { DateTime dt = DateTime.Now; string timeStart = string.Format("{0:yyyyMMddHHmmss}", dt); string timeExpire = string.Format("{0:yyyyMMddHHmmss}", dt.AddSeconds(300)); SortedDictionary <string, string> ht = new SortedDictionary <string, string> { { "appid", ConfigurationManager.AppSettings["APPID"] }, { "mch_id", ConfigurationManager.AppSettings["MCHID"] }, { "device_info", "WEB" }, { "nonce_str", RandomHelper.GenerateString(32) }, { "sign_type", "MD5" }, { "body", request.Body }, { "detail", request.Detail }, { "attach", request.Attach }, { "out_trade_no", request.OutTradeNo }, { "fee_type", "CNY" }, { "total_fee", "" + request.TotalFee }, { "spbill_create_ip", request.SpbillCreateIp }, { "time_start", timeStart }, { "time_expire", timeExpire }, { "goods_tag", request.GoodsTag }, { "notify_url", ConfigurationManager.AppSettings["NOTIFYURL"] }, { "trade_type", "JSAPI" }, { "openid", request.Openid }, { "product_id", request.ProductId } }; if (string.IsNullOrEmpty(request.LimitPay)) { if (request.LimitPay == "no_credit") { ht.Add("limit_pay", "no_credit"); } } string sign = Md5Helper.UserMd5(WxPayHelper.CreateSign(ht)); ht.Add("sign", sign); string postXml = WxPayHelper.CreateXmlRequest(ht); string wxResult = HttpRequestUtil.HttpPost(UrlUnifiedorder, postXml); Hashtable htt = XmlAndJsonToHash.XmlToHashTable(wxResult); wxResult = JsonHelper.ToJson(htt); CoResponse tr = JsonHelper.Deserialize <CoResponse>(wxResult); response.ResponseStatus.ErrorCode = tr.return_code; response.ResponseStatus.Message = tr.return_msg; if (tr.return_code == "SUCCESS" && tr.result_code == "SUCCESS") { response.PrepayId = tr.prepay_id; } else { response.ResponseStatus.ErrorCode = tr.err_code; response.ResponseStatus.Message = tr.err_code_des; } }