Beispiel #1
0
        /// <summary>
        /// 订单支付通知
        /// </summary>
        public void POSOrderPaidNotify()
        {
            try
            {
                Dictionary <string, string> param = HttpUtility.UrlDecode(content).ToDictionary(true);

                if (!param.ContainsKey("bizseq"))
                {
                    throw new Exception("bizseq不能为空");
                }

                string bizseq = param["bizseq"];

                var orderPaid = iOrderPaidService.Get(t => t.OrderNumber == bizseq);

                if (orderPaid == null)
                {
                    throw new Exception("订单不存在:" + bizseq);
                }

                //获取支付参数
                var preferences = iPreferencesService.Get(t => t.MerchantID == orderPaid.MerchantID);
                this.vspExec = new VSPExec(preferences.POSBaoMerchant, preferences.POSBaoKey, preferences.APPID);

                if (vspExec.IsVerify(param))//验签成功
                {
                    POSOrderQueryResponse posOrderQueryResponse = JsonHelper.Deserialize <POSOrderQueryResponse>(JsonHelper.Serialize(param));
                    byte[] bytes = Encoding.GetEncoding("gbk").GetBytes(posOrderQueryResponse.trxreserve ?? ""); //将字符串转成gbk编码的字节数组
                    posOrderQueryResponse.trxreserve = Encoding.GetEncoding("utf-8").GetString(bytes);           //将字节数组转回为字符串

                    if (posOrderQueryResponse.trxcode == "VSP001" && posOrderQueryResponse.trxstatus == "0000")
                    {
                        //订单支付成功后的平安和光大订单的后续处理
                        iOrderPaidService.VspOrderHandle(posOrderQueryResponse, orderPaid);

                        Response.Write("success");
                    }
                }
                else
                {
                    throw new Exception("通知验签失败");
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                Response.Write("error");
            }
        }
        /// <summary>
        /// 百富POS调订单支付通知
        /// </summary>
        public void POSOrderPaidNotify()
        {
            Dictionary <string, string> param = HttpUtility.UrlDecode(content).ToDictionary(true);

            if (!param.ContainsKey("bizseq"))
            {
                Response.Write("error");
            }

            string bizseq = param["bizseq"];

            var orderPaid = iOrderPaidService.Get(t => t.OrderNumber == bizseq);

            if (orderPaid == null)
            {
                Response.Write("error");
                return;
            }

            //测试使用: 平安的订单,订单支付后通知转发到平安的通知方法
            if (orderPaid.Merchant.AccountBank == AccountBankOption.PingAn.ToInt())
            {
                string url = "http://112.95.232.217:8023/PingAnNotify/POSOrderPaidNotify";
                Framework.Requests.Request.Post(url, content, System.Net.SecurityProtocolType.Tls12);
                //RedirectToAction("POSOrderPaidNotify", "PingAnNotify", content);
                return;
            }

            //测试使用: 光大的订单,订单支付后通知转发到光大的通知方法
            if (orderPaid.Merchant.AccountBank == AccountBankOption.GuangDa.ToInt())
            {
                string url = "http://112.95.232.217:8023/Notify/POSOrderPaidNotify";
                Framework.Requests.Request.Post(url, content, System.Net.SecurityProtocolType.Tls12);
                return;
            }
        }
        public ActionResult Details(long ID)
        {
            var model = iOrderPaidService.Get(ID);

            return(View(model));
        }