Ejemplo n.º 1
0
        private Dictionary <string, string> GenParams(ViewModel.PaymentViewModel model)
        {
            var dict = new Dictionary <string, string>();

            // 交易类型,前台只支持CONSUME 和 PRE_AUTH
            dict.Add("transType", UPOPSrv.TransType.CONSUME);
            // 商品URL
            dict.Add("commodityUrl", model.ProdUrl);
            // 商品名称
            dict.Add("commodityName", model.ProdName);
            // 商品单价,分为单位
            dict.Add("commodityUnitPrice", Ichari.Common.WebUtils.ConvertToFen(model.OrderModel.Total));
            // 商品数量
            dict.Add("commodityQuantity", model.OrderModel.OrderDetail.Sum(t => t.ProductCount).ToString());
            // 订单号,必须唯一
            dict.Add("orderNumber", model.OrderModel.TradeNo);
            // 交易金额
            dict.Add("orderAmount", Ichari.Common.WebUtils.ConvertToFen(model.OrderModel.Total));
            // 币种
            dict.Add("orderCurrency", UPOPSrv.CURRENCY_CNY);
            // 交易时间
            dict.Add("orderTime", model.OrderModel.CreateTime.ToString("yyyyMMddHHmmss"));
            // 用户IP
            dict.Add("customerIp", Request.UserHostAddress);
            // 前台回调URL
            dict.Add("frontEndUrl", model.FrontCallbackUrl);
            // 后台回调URL(前台请求时可为空)
            dict.Add("backEndUrl", model.BackCallbackUrl);

            return(dict);
        }
Ejemplo n.º 2
0
        public void Submit(ViewModel.PaymentViewModel model)
        {
            var order = _uow.OrderService.Get(t => t.OrderId == model.OrderId && t.TradeNo == model.TradeNo);

            if (order == null)
            {
                Response.Redirect("PayError");
            }
            model.OrderModel = order;

            model.FrontCallbackUrl = Ichari.Common.WebUtils.GetAppSettingValue("FrontPayUrl");
            model.BackCallbackUrl  = Ichari.Common.WebUtils.GetAppSettingValue("BackPayUrl");

            if (model.Source == Model.Enum.PaySource.Donation)
            {
                model.ProdUrl  = Ichari.Common.WebUtils.GetAppSettingValue("DonateUrl");
                model.ProdName = Ichari.Common.WebUtils.GetAppSettingValue("DonationName");
            }
            switch (model.PayWayType)
            {
            case PayWay.UnionPay:
                // 要使用各种Srv必须先使用LoadConf载入配置
                UPOPSrv.LoadConf(Server.MapPath("~/conf.xml.config"));

                var p   = GenParams(model);
                var srv = new FrontPaySrv(p);
                //写入订单支付记录
                SavePayLog(model);

                Response.ContentEncoding = srv.Charset;
                _log.Info(srv.CreateHtml());
                Response.Write(srv.CreateHtml());
                break;
            }
        }
Ejemplo n.º 3
0
        public ActionResult Index(ViewModel.PaymentViewModel model)
        {
            //todo:还需要处理session信息
            var order = _uow.OrderService.Get(t => t.OrderId == model.OrderId && t.TradeNo == model.TradeNo);

            if (order == null)
            {
                return(RedirectToAction("PayError"));
            }
            if (order.Status >= (int)Ichari.Model.Enum.OrderState.Paid)
            {
                return(RedirectToAction("PayError"));
            }
            model.OrderModel = order;
            return(View(model));
        }
Ejemplo n.º 4
0
        private void SavePayLog(ViewModel.PaymentViewModel model)
        {
            var paylog = new PayLog();

            paylog.OrderId = model.OrderModel.OrderId;
            //paylog.TransactionId = model.OrderModel.TradeNo;
            paylog.UserId     = model.OrderModel.UserId;
            paylog.PayWay     = (int)PayWay.UnionPay;
            paylog.PayMoney   = model.OrderModel.Total;
            paylog.PayUrl     = "";
            paylog.BackUrl    = model.BackCallbackUrl;
            paylog.PayResult  = "前往支付";
            paylog.CreateTime = DateTime.Now;

            _uow.PayLogService.Add(paylog);
            _uow.Commit();
        }