예제 #1
0
    private string CreateQRCodeUrl()
    {
        Dictionary <string, string> dic = new Dictionary <string, string>();

        dic.Add("appid", helper.GetAppId);
        dic.Add("mch_id", helper.GetMch_Id);
        dic.Add("nonce_str", WpPCHelper.TenpayUtil.getNoncestr().ToLower());//TenpayUtil.getNoncestr()
        dic.Add("product_id", nID);
        dic.Add("time_stamp", WpPCHelper.TenpayUtil.getTimestamp());
        #region sign===============================
        Sign = helper.GetSign(dic);
        LogUtil.WriteLog("sign:" + Sign);
        dic.Add("sign", Sign);
        #endregion

        string urlce = WxPayHelper.FormatBizQueryParaMap(dic, false);//这里不要url编码

        LogUtil.WriteLog("urlce:" + urlce);

        string url = string.Format(@"sign={0}&appid={1}&mch_id={2}&product_id={3}&time_stamp={4}&nonce_str={5}"
                                   , Sign, helper.GetAppId, helper.GetMch_Id, nID, WpPCHelper.TenpayUtil.getTimestamp(), WpPCHelper.TenpayUtil.getNoncestr().ToLower());
        LogUtil.WriteLog("二维码地址生成" + url);
        return("weixin://wxpay/bizpayurl?" + urlce);


        /*------另一种方式--------*/

        //var packageReqHandler = new RequestHandler(Context);
        ////初始化
        //packageReqHandler.init();
        ////设置package订单参数  具体参数列表请参考官方pdf文档,请勿随意设置
        //packageReqHandler.setParameter("appid", PayConfig.AppId);
        //packageReqHandler.setParameter("mch_id", PayConfig.MchId);
        //packageReqHandler.setParameter("nonce_str", WeiPay.TenpayUtil.getNoncestr().ToLower());
        //packageReqHandler.setParameter("product_id", nID);
        //packageReqHandler.setParameter("time_stamp", WeiPay.TenpayUtil.getTimestamp());
        //#region sign===============================
        //Sign = packageReqHandler.CreateMd5Sign("key", PayConfig.AppKey);
        //LogUtil.WriteLog("WeiPay 页面  sign:" + Sign);
        //packageReqHandler.setParameter("sign", Sign);
        //#endregion
        //string data = packageReqHandler.parseXML();
        //LogUtil.WriteLog("WeiPay 页面  package(XML):" + data);
        //string url = string.Format(@"sign={0}&appid={1}&mch_id={2}&product_id={3}&time_stamp={4}&nonce_str={5}"
        //    , Sign, PayConfig.AppId, PayConfig.MchId, nID, WeiPay.TenpayUtil.getTimestamp(), WeiPay.TenpayUtil.getNoncestr().ToLower());
        //LogUtil.WriteLog("WeiPay 页面  package(XML):" + url);
        //return "weixin://wxpay/bizpayurl?" + url;
    }