/// <summary> /// 统一下单 /// </summary> /// <returns></returns> public OrderResp unifiedOrder(OrderReq req) { //todo:微信登录 const string reqUrl = "https://api.mch.weixin.qq.com/pay/unifiedorder"; string openId = Session["openId"].ToString(); if (string.IsNullOrEmpty(openId)) { throw new XException("用户没有登录微信"); } if (string.IsNullOrEmpty(req.out_trade_no)) { throw new XException("商家订单号(out_trade_no)必须提供"); } if (req.total_fee < 1) { throw new XException("订单金额(total_fee)必须提供"); } req.appid = WxConfigFile.config().AppID; req.mch_id = WxConfigFile.config().MchId; req.trade_type = TradeType.JSAPI.ToString(); req.nonce_str = PayUtil.GetNoncestr(); req.notify_url = WxConfigFile.config().Domain + "/WxPay.orderNotify.call"; req.openid = openId; req.sign = WeiXinUtils.getSign(req, WxConfigFile.config().SignKey); return(req.send <OrderResp>(reqUrl)); // return WeiXinUtils.Post<OrderResp>(req, reqUrl); // req.sign = ""; }