public void NativePayTest() { var result = TenPay.NativePay("[appId]", "[timesTamp]", "[nonceStr]", "[productId]", "[sign]"); Console.Write(result); Assert.IsNotNull(result); }
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()); }