Пример #1
0
 public AdminController(
     ICacheService cacheService,
     IConfigService configService,
     IDicDataService dicDataService,
     IUserService userService,
     IMenuService menuService,
     IPayService payService,
     IAUserService auserService
     )
 {
     _cacheService = cacheService;
     _configService = configService;
     _dicDataService = dicDataService;
     _userService = userService;
     _menuService = menuService;
     _payService = payService;
     _auserService = auserService;
 }
Пример #2
0
        /// <summary>
        /// Handles online payment service async or sync notify.
        /// </summary>
        /// <param name="payServiceName"></param>
        /// <param name="isNotify"></param>
        /// <returns></returns>
        private string HandlePayResultAndNotify(string payServiceName, bool isNotify, out string returnUrl)
        {
            string responseCodeOrOrderId = string.Empty;
            returnUrl = string.Empty;

            try
            {
                payService = BuildPayService(payServiceName);
                payService.CheckNullObject("Online Payment Service");

                NameValueCollection reqResult = BuildRequestResult(payService, isNotify);
                responseCodeOrOrderId = payService.ResponseCodeFailed;

                if (payService.Verify(reqResult))
                {
                    PayResult result = payService.ParseResult(reqResult);
                    if (UpdateOrder(result, out returnUrl))
                    {
                        responseCodeOrOrderId = payService.ResponseCodeSucceed;
                    }

                    if (!isNotify)
                    {
                        responseCodeOrOrderId = result.OrderId;
                    }
                }
                else
                {
                    LogService.Log(payService.CurrentPayment + " verify failed.", reqResult.ToString());
                }
            }
            catch (Exception e)
            {
                LogService.Log(payService.CurrentPayment + "result or notify got an exception", e.ToString());
                responseCodeOrOrderId = payService.CurrentPayment + "result or notify got an exception";
            }

            return responseCodeOrOrderId;
        }
Пример #3
0
        /// <summary>
        /// Translates request result from online payment service async or sync request stream.
        /// </summary>
        /// <param name="service"></param>
        /// <param name="isNotify"></param>
        /// <returns></returns>
        private NameValueCollection BuildRequestResult(IPayService service, bool isNotify)
        {
            NameValueCollection reqResult = new NameValueCollection();

            if (service.CurrentPayment.Equals(PaymentService.CHINABANKSERVICE, StringComparison.CurrentCultureIgnoreCase))
            {
                Request.ContentEncoding = Encoding.GetEncoding("GBK");
                reqResult = PayUtil.DecodeRequest(Request.InputStream);
            }
            else if (service.CurrentPayment.Equals(PaymentService.ALIPAYSERVICE, StringComparison.CurrentCultureIgnoreCase))
            {
                if (isNotify)
                {
                    reqResult = Request.Form;
                }
                else
                {
                    reqResult = Request.QueryString;
                }
            }
            else if (service.CurrentPayment.Equals(PaymentService.TENPAYSERVICE, StringComparison.CurrentCultureIgnoreCase))
            {
                reqResult = Request.QueryString;
            }
            else
            {
                // do nothing.
            }

            return reqResult;
        }
Пример #4
0
        public ActionResult PayOnline(string orderId, string payment)
        {
            string responseHtml = "";

            try
            {
                // 取消其他在线支付方式,只支持支付宝,强制设置
                payment = PaymentService.ALIPAYSERVICE;

                //客户端IP地址
                string clientIPAddr = GetUserIp();

                payService = BuildPayService(payment);

                if (payService != null)
                {
                    TradeOrder order = orderService.GetOrderByOrderId(orderId);

                    if (order != null && !string.IsNullOrEmpty(order.OrderId))
                    {
                        PayRequestCriteria criteria = new PayRequestCriteria();
                        criteria.OrderId = order.OrderId;
                        criteria.Amount = order.Amount.ToString();
                        criteria.Subject = order.Subject;
                        criteria.Body = order.Body;
                        criteria.ClientIP = clientIPAddr;
                        //criteria.AddCustomParameter("", "");

                        responseHtml = payService.BuildRequest(criteria);
                    }
                    else
                    {
                        responseHtml = "订单:" + orderId + "不存在";
                    }
                }
                else
                {
                    responseHtml = "The pay service " + payment + " does not support.";
                }
            }
            catch (Exception e)
            {
                LogService.Log("PayOnline Failed", e.ToString());
            }

            return Content(responseHtml);
        }
Пример #5
0
 public HomeController(IPayService payTest, PayService pay)
 {
     _payTest = payTest;
     _pay     = pay;
 }