CreateSHA1Sign() public method

创建sha1签名
public CreateSHA1Sign ( ) : string
return string
Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string sp_billno = Request["order_no"];
        //当前时间 yyyyMMdd
        string date = DateTime.Now.ToString("yyyyMMdd");

        if (null == sp_billno)
        {
            //生成订单10位序列号,此处用时间和随机数生成,商户根据自己调整,保证唯一
            sp_billno = DateTime.Now.ToString("HHmmss") + TenPayUtil.BuildRandomStr(4);
        }
        else
        {
            sp_billno = Request["order_no"].ToString();
        }

        sp_billno = TenPayInfo.PartnerId + sp_billno;

        //创建支付应答对象
        RequestHandler packageReqHandler = new RequestHandler(Context);
        //初始化
        packageReqHandler.Init();


        //设置package订单参数
        packageReqHandler.SetParameter("partner", TenPayInfo.PartnerId);		  //商户号
        packageReqHandler.SetParameter("fee_type", "1");                    //币种,1人民币
        packageReqHandler.SetParameter("input_charset", "GBK");
        packageReqHandler.SetParameter("out_trade_no", sp_billno);		//商家订单号
        packageReqHandler.SetParameter("total_fee", "1");			        //商品金额,以分为单位(money * 100).ToString()
        packageReqHandler.SetParameter("notify_url", TenPayInfo.TenPayNotify);		    //接收财付通通知的URL
        packageReqHandler.SetParameter("body", "JSAPIdemo");	                    //商品描述
        packageReqHandler.SetParameter("spbill_create_ip", Page.Request.UserHostAddress);   //用户的公网ip,不是商户服务器IP

        //获取package包
        packageValue = packageReqHandler.GetRequestURL();

        //调起微信支付签名
        timeStamp = TenPayUtil.GetTimestamp();
        nonceStr = TenPayUtil.GetNoncestr();

        //设置支付参数
        RequestHandler paySignReqHandler = new RequestHandler(Context);
        paySignReqHandler.SetParameter("appid", appId);
        paySignReqHandler.SetParameter("appkey", TenPayInfo.AppKey);
        paySignReqHandler.SetParameter("noncestr", nonceStr);
        paySignReqHandler.SetParameter("timestamp", timeStamp);
        paySignReqHandler.SetParameter("package", packageValue);
        paySign = paySignReqHandler.CreateSHA1Sign();



        //获取debug信息,建议把请求和debug信息写入日志,方便定位问题
        //string pakcageDebuginfo = packageReqHandler.getDebugInfo();
        //Response.Write("<br/>pakcageDebuginfo:" + pakcageDebuginfo + "<br/>");
        //string paySignDebuginfo = paySignReqHandler.getDebugInfo();
        //Response.Write("<br/>paySignDebuginfo:" + paySignDebuginfo + "<br/>");


    }
Esempio n. 2
0
        /// <summary>
        /// 取得微信JsSdk相关参数值
        /// </summary>
        /// <param name="appId">微信应用ID</param>
        /// <param name="ticket">JsTicket</param>
        /// <param name="url">需要授权Url地址</param>
        /// <returns></returns>
        public JsSdkResp GetJsSdk(string appId, string ticket, string url)
        {
            var    decodeUrl = HttpUtility.UrlDecode(url);
            string timeStamp = TenPayV3Util.GetTimestamp();
            string nonceStr  = TenPayV3Util.GetNoncestr();

            string signature = "";

            Senparc.Weixin.MP.TenPayLib.RequestHandler paySignReqHandler = new Senparc.Weixin.MP.TenPayLib.RequestHandler(null);

            paySignReqHandler.SetParameter("jsapi_ticket", ticket);
            paySignReqHandler.SetParameter("noncestr", nonceStr);
            paySignReqHandler.SetParameter("timestamp", timeStamp);
            paySignReqHandler.SetParameter("url", decodeUrl);

            signature = paySignReqHandler.CreateSHA1Sign();

            return(new JsSdkResp
            {
                AppId = appId,
                Timestamp = timeStamp,
                NonceStr = nonceStr,
                Signature = signature
            });
        }
        public ActionResult Delivernotify()
        {
            string timeStamp = "";
            string appSignature = "";
            //string appId, string openId, string transId, string out_Trade_No, string deliver_TimesTamp, string deliver_Status, string deliver_Msg, string app_Signature,
            string sp_billno = Request["order_no"];
            //当前时间 yyyyMMdd
            string date = DateTime.Now.ToString("yyyyMMdd");

            if (null == sp_billno)
            {
                //生成订单10位序列号,此处用时间和随机数生成,商户根据自己调整,保证唯一
                sp_billno = DateTime.Now.ToString("HHmmss") + TenPayUtil.BuildRandomStr(4);
            }
            else
            {
                sp_billno = Request["order_no"].ToString();
            }

            sp_billno = TenPayInfo.PartnerId + sp_billno;

            //调起微信支付签名
            timeStamp = TenPayUtil.GetTimestamp();

            //设置支付参数
            RequestHandler paySignReqHandler = new RequestHandler(null);
            paySignReqHandler.SetParameter("appid", TenPayInfo.AppId);
            paySignReqHandler.SetParameter("openId", TenPayInfo.AppKey);
            paySignReqHandler.SetParameter("transId", "111112222233333");
            paySignReqHandler.SetParameter("deliver_TimesTamp", timeStamp);
            paySignReqHandler.SetParameter("out_Trade_No", sp_billno);
            paySignReqHandler.SetParameter("deliver_Status", "1");
            paySignReqHandler.SetParameter("deliver_Msg", "ok");
            appSignature = paySignReqHandler.CreateSHA1Sign();
            var result = TenPay.Delivernotify(TenPayInfo.AppId, "oX99MDgNcgwnz3zFN3DNmo8uwa-w", "111112222233333", sp_billno,
                                 timeStamp, "1", "ok", appSignature, "sha1");

            ViewData["message"] = result.errcode;
            return View();
        }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string sp_billno = Request["order_no"];
        //当前时间 yyyyMMdd
        string date = DateTime.Now.ToString("yyyyMMdd");
        //订单号,此处用时间和随机数生成,商户根据自己调整,保证唯一
        string out_trade_no = "" + DateTime.Now.ToString("HHmmss") + TenPayUtil.BuildRandomStr(4);

        if (null == sp_billno)
        {
            //生成订单10位序列号,此处用时间和随机数生成,商户根据自己调整,保证唯一
            sp_billno = DateTime.Now.ToString("HHmmss") + TenPayUtil.BuildRandomStr(4);
        }
        else
        {
            sp_billno = Request["order_no"].ToString();
        }

        sp_billno = TenPayInfo.PartnerId + sp_billno;



        //创建RequestHandler实例
        RequestHandler packageReqHandler = new RequestHandler(Context);
        //初始化
        packageReqHandler.Init();
        packageReqHandler.SetKey(TenPayInfo.Key);

        //设置package订单参数
        packageReqHandler.SetParameter("partner", TenPayInfo.PartnerId);		  //商户号
        packageReqHandler.SetParameter("bank_type", "WX");		                      //银行类型
        packageReqHandler.SetParameter("fee_type", "1");                    //币种,1人民币
        packageReqHandler.SetParameter("input_charset", "GBK");
        packageReqHandler.SetParameter("out_trade_no", sp_billno);		//商家订单号
        packageReqHandler.SetParameter("total_fee", "1");			        //商品金额,以分为单位(money * 100).ToString()
        packageReqHandler.SetParameter("notify_url", TenPayInfo.TenPayNotify);		    //接收财付通通知的URL
        packageReqHandler.SetParameter("body", "nativecall");	                    //商品描述
        packageReqHandler.SetParameter("spbill_create_ip", Page.Request.UserHostAddress);   //用户的公网ip,不是商户服务器IP

        //获取package包
        string  packageValue = packageReqHandler.GetRequestURL();

        //调起微信支付签名
        string timeStamp = TenPayUtil.GetTimestamp();
        string nonceStr = TenPayUtil.GetNoncestr();

        //设置支付参数
        RequestHandler payHandler = new RequestHandler(Context);
        payHandler.SetParameter("appid", TenPayInfo.AppId);
        payHandler.SetParameter("noncestr", nonceStr);
        payHandler.SetParameter("timestamp", timeStamp);
        payHandler.SetParameter("package", packageValue);
        payHandler.SetParameter("RetCode","0");
        payHandler.SetParameter("RetErrMsg","成功");
        string paySign = payHandler.CreateSHA1Sign();
        payHandler.SetParameter("app_signature", paySign);
        payHandler.SetParameter("sign_method","SHA1");


        Response.ContentType = "text/xml";
        Response.Clear();
        Response.Write(payHandler.ParseXML());

    }
Esempio n. 5
0
        public ActionResult Native()
        {
            string sp_billno = Request["order_no"];
            //当前时间 yyyyMMdd
            string date = DateTime.Now.ToString("yyyyMMdd");

            if (null == sp_billno)
            {
                //生成订单10位序列号,此处用时间和随机数生成,商户根据自己调整,保证唯一
                sp_billno = DateTime.Now.ToString("HHmmss") + TenPayUtil.BuildRandomStr(4);
            }
            else
            {
                sp_billno = Request["order_no"].ToString();
            }

            sp_billno = TenPayInfo.PartnerId + sp_billno;

            RequestHandler outParams = new RequestHandler(null);

            outParams.Init();
            string productid = sp_billno;
            string timeStamp = TenPayUtil.GetTimestamp();
            string nonceStr = TenPayUtil.GetNoncestr();

            RequestHandler Params = new RequestHandler(null);
            Params.SetParameter("appid", TenPayInfo.AppId);
            Params.SetParameter("appkey", TenPayInfo.AppKey);
            Params.SetParameter("noncestr", nonceStr);
            Params.SetParameter("timestamp", timeStamp);
            Params.SetParameter("productid", productid);
            string sign = Params.CreateSHA1Sign();
            Params.SetParameter("sign", sign);

            var parm = TenPay.NativePay(TenPayInfo.AppId, timeStamp, nonceStr, productid, sign);
            parm = QRCode.QRfromGoogle(parm);
            ViewData["parm"] = parm;
            return View();
        }
Esempio n. 6
0
        public ActionResult SharedAddress()
        {
            var accessToken = AccessTokenContainer.TryGetAccessToken(TenPayInfo.AppId, "49b71198b776e18521659a32a97501a6");

            string timeStamp = TenPayUtil.GetTimestamp();
            string nonceStr = TenPayUtil.GetNoncestr();

            RequestHandler paySignReqHandler = new RequestHandler(null);
            paySignReqHandler.SetParameter("accessToken", accessToken);
            paySignReqHandler.SetParameter("appid", TenPayInfo.AppId);
            paySignReqHandler.SetParameter("nonceStr", nonceStr);
            paySignReqHandler.SetParameter("timeStamp", timeStamp);
            paySignReqHandler.SetParameter("url", TenPayInfo.TenPayNotify);
            var addrSign = paySignReqHandler.CreateSHA1Sign();

            ViewData["appId"] = TenPayInfo.AppId;
            ViewData["addrSign"] = addrSign;
            ViewData["timeStamp"] = timeStamp;
            ViewData["nonceStr"] = nonceStr;

            return View();
        }
Esempio n. 7
0
        public ActionResult JsApi()
        {
            //string appId = TenPayInfo.AppId;
            string timeStamp = "";
            string nonceStr = "";
            string packageValue = "";
            string paySign = "";

            string sp_billno = Request["order_no"];
            //当前时间 yyyyMMdd
            string date = DateTime.Now.ToString("yyyyMMdd");

            if (null == sp_billno)
            {
                //生成订单10位序列号,此处用时间和随机数生成,商户根据自己调整,保证唯一
                sp_billno = DateTime.Now.ToString("HHmmss") + TenPayUtil.BuildRandomStr(4);
            }
            else
            {
                sp_billno = Request["order_no"].ToString();
            }

            sp_billno = TenPayInfo.PartnerId + sp_billno;

            //创建支付应答对象
            RequestHandler packageReqHandler = new RequestHandler(null);
            //初始化
            packageReqHandler.Init();
            packageReqHandler.SetKey(TenPayInfo.Key);

            //设置package订单参数
            packageReqHandler.SetParameter("partner", TenPayInfo.PartnerId);		  //商户号
            packageReqHandler.SetParameter("fee_type", "1");                    //币种,1人民币
            packageReqHandler.SetParameter("input_charset", "GBK");
            packageReqHandler.SetParameter("bank_type", "WX");
            packageReqHandler.SetParameter("out_trade_no", sp_billno);		//商家订单号
            packageReqHandler.SetParameter("total_fee", "1");			        //商品金额,以分为单位(money * 100).ToString()
            packageReqHandler.SetParameter("notify_url", TenPayInfo.TenPayNotify);		    //接收财付通通知的URL
            packageReqHandler.SetParameter("body", "JSAPIdemo");	                    //商品描述
            packageReqHandler.SetParameter("spbill_create_ip", Request.UserHostAddress);   //用户的公网ip,不是商户服务器IP

            //获取package包
            packageValue = packageReqHandler.GetRequestURL();

            //调起微信支付签名
            timeStamp = TenPayUtil.GetTimestamp();
            nonceStr = TenPayUtil.GetNoncestr();

            //设置支付参数
            RequestHandler paySignReqHandler = new RequestHandler(null);
            paySignReqHandler.SetParameter("appid", TenPayInfo.AppId);
            paySignReqHandler.SetParameter("appkey", TenPayInfo.AppKey);
            paySignReqHandler.SetParameter("noncestr", nonceStr);
            paySignReqHandler.SetParameter("timestamp", timeStamp);
            paySignReqHandler.SetParameter("package", packageValue);
            paySign = paySignReqHandler.CreateSHA1Sign();
            //TenPay.Delivernotify(TenPayInfo.AppId, "oX99MDgNcgwnz3zFN3DNmo8uwa-w", "111112222233333", sp_billno,
            //                     timeStamp, "1", "ok", "53cca9d47b883bd4a5c85a9300df3da0cb48565c", "sha1");

            //获取debug信息,建议把请求和debug信息写入日志,方便定位问题
            //string pakcageDebuginfo = packageReqHandler.getDebugInfo();
            //Response.Write("<br/>pakcageDebuginfo:" + pakcageDebuginfo + "<br/>");
            //string paySignDebuginfo = paySignReqHandler.getDebugInfo();
            //Response.Write("<br/>paySignDebuginfo:" + paySignDebuginfo + "<br/>");

            //TODO:和JSSDK一样整合信息包
            ViewData["appId"] = TenPayInfo.AppId;
            ViewData["timeStamp"] = timeStamp;
            ViewData["nonceStr"] = nonceStr;
            ViewData["packageValue"] = packageValue;
            ViewData["paySign"] = paySign;

            return View();
        }
Esempio n. 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string sp_billno = Request["order_no"];
        //当前时间 yyyyMMdd
        string date = DateTime.Now.ToString("yyyyMMdd");

        if (null == sp_billno)
        {
            //生成订单10位序列号,此处用时间和随机数生成,商户根据自己调整,保证唯一
            sp_billno = DateTime.Now.ToString("HHmmss") + TenPayUtil.BuildRandomStr(4);
        }
        else
        {
            sp_billno = Request["order_no"].ToString();
        }

        sp_billno = TenPayInfo.PartnerId + sp_billno;

        
        RequestHandler outParams = new RequestHandler(Context);
        
        outParams.Init();
        string productid = sp_billno;
        string timeStamp = TenPayUtil.GetTimestamp();
        string nonceStr = TenPayUtil.GetNoncestr();

        RequestHandler Params = new RequestHandler(Context);
        Params.SetParameter("appid", TenPayInfo.AppId);
        Params.SetParameter("appkey", TenPayInfo.AppKey);
        Params.SetParameter("noncestr", nonceStr);
        Params.SetParameter("timestamp", timeStamp);
        Params.SetParameter("productid", productid);
        string sign = Params.CreateSHA1Sign();
        Params.SetParameter("sign",sign);


        parm = "weixin://wxpay/bizpayurl?sign=" + sign + "&appid=" + TenPayInfo.AppId + "&productid=" + productid + "&timeStamp=" + timeStamp + "&nonceStr=" + nonceStr;
        parm = QRfromGoogle(parm);
      
    }