/// <summary> /// 生成统一下单交易数据包(为pc端网页扫码模式) /// </summary> /// <param name="orderId"></param> /// <param name="money"></param> /// <param name="body"></param> /// <param name="notifyUrl"></param> /// <param name="expire"></param> /// <param name="userOpenId">用户openid</param> /// <param name="ip"></param> private string genPrePay4Qrcode(string orderId, decimal money, string body, string notifyUrl, DateTime expire, string ip) { string noncestr = Guid.NewGuid().ToString().Replace("-", ""); //32 位内的随机串,防重发 var param = new SortedDictionary <string, object>(); param.Add("appid", config.AppId); param.Add("mch_id", config.MerchantId); param.Add("nonce_str", noncestr); param.Add("device_info", "WEB"); param.Add("body", body); param.Add("out_trade_no", orderId); param.Add("total_fee", Convert.ToInt32(Math.Round(money * 100, 0))); //订单总金额,单位为分 param.Add("spbill_create_ip", ip); param.Add("notify_url", notifyUrl); param.Add("product_id", orderId); param.Add("trade_type", "NATIVE"); if (expire != DateTime.MinValue) { param.Add("time_expire", expire.ToString("yyyyMMddHHmmss")); } //生成签名 string signString = WxpayCore.CreateLinkString(param) + "&key=" + config.MerchantKey; string packSign = WxpayCore.MD5(signString, Encoding.UTF8); param.Add("sign", packSign); return(WxpayCore.ToXml(param)); }
/// <summary> /// 生成订单查询XML /// </summary> /// <param name="orderId"></param> private string generateOrderQueryByOrderId(string orderId) { string noncestr = Guid.NewGuid().ToString().Replace("-", ""); //32 位内的随机串,防重发 var param = new SortedDictionary <string, object>(); param.Add("appid", config.AppId); param.Add("mch_id", config.MerchantId); param.Add("nonce_str", noncestr); param.Add("out_trade_no", orderId); //生成签名 string signString = WxpayCore.CreateLinkString(param) + "&key=" + config.MerchantKey; string packSign = WxpayCore.MD5(signString, Encoding.UTF8); param.Add("sign", packSign); return(WxpayCore.ToXml(param)); }