Ejemplo n.º 1
0
        public ActionResult Index()
        {
            string privateKey = ConfigurationManager.AppSettings["privateKey"];

            PayShowModel payShowModel = new PayShowModel()
            {
                tradeNo = Guid.NewGuid().ToString("N")
            };
            Dictionary <string, object> dict = new Dictionary <string, object>();

            dict.Add("signType", "RSA");
            dict.Add("appId", "qTCH30NzGx4Kws9k");
            dict.Add("payMode", "ActiveCode");
            dict.Add("tradeType", ConfigurationManager.AppSettings["tradeType"]);
            dict.Add("merchantSn", ConfigurationManager.AppSettings["merchantSn"]);
            dict.Add("outTradeNo", payShowModel.tradeNo);
            dict.Add("totalFee", 1);
            dict.Add("notifyUrl", "https://uat_activity.niceloo.com/Notify");//HttpUtility.UrlEncode("
            dict.Add("attach", "000");
            string sign = PayHelper.Sign(dict, privateKey);

            dict.Add("goodsBody", "商品名称介绍");
            dict.Add("goodsDetail", "商品详细介绍");

            dict.Add("sign", sign);
            //发送请求
            string result = PayHelper.SendPost("https://open.smart4s.com/Api/Service/Pay/Mode/trade", dict);

            Response.Write("请求结果:" + result);

            PayResult payResult = Newtonsoft.Json.JsonConvert.DeserializeObject <PayResult>(result);

            if (payResult != null && payResult.data != null)
            {
                payShowModel.PayImgUrl = PayHelper.GenerateImgCode("", payResult.data.payQRCodeUrl);
            }
            return(View(payShowModel));
        }