protected void Page_Load(object sender, EventArgs e)
        {
            var payData   = Request.QueryString["payData"];
            var ticket    = Request.QueryString["ticket"];
            var payStatus = Request.QueryString["payStatus"];

            if (!string.IsNullOrEmpty(payData) && !string.IsNullOrEmpty(ticket))
            {
                payData = EncryptionManager.AESDecrypt(payData, ticket);

                var payDataModel = JSONHelper.Deserialize <UnifiedOrderEntity>(payData);

                if (payDataModel != null)
                {
                    dingdanidnum = payDataModel.Extra["dingdanidnum"];
                    openid       = payDataModel.Extra["openid"];
                    hotelid      = payDataModel.Extra["hotelid"];
                    roomid       = payDataModel.Extra["roomid"];
                    JumpUrl(payStatus);
                }
                else
                {
                    dingdanidnum = Request.QueryString["dingdanidnum"];
                    openid       = Request.QueryString["openid"];
                    hotelid      = Request.QueryString["hotelid"];
                    roomid       = Request.QueryString["roomid"];
                    JumpUrl(payStatus);
                }
            }
            else
            {
                Response.Clear();
                Response.Write("不完整的参数");
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            payStatus = Request.QueryString["PayStatus"];
            var payData = Request.QueryString["payData"];
            var ticket  = Request.QueryString["ticket"];

            payData = EncryptionManager.AESDecrypt(payData, ticket);
            var payDataModel = JSONHelper.Deserialize <UnifiedOrderEntity>(payData);

            shopid = Convert.ToInt32(payDataModel.Extra["shopid"]);
            switch (payStatus.ToLower())
            {
            case "success":
                //支付成功,清空购物车,跳转到当前店铺订单列表
                clearCache = "cart.clear();";
                newUrl     =
                    string.Format(
                        "../restaurant/diancai_orderDetail.aspx?wid={0}&shopid={1}&dingdan={2}&openid={3}",
                        payDataModel.wid,
                        payDataModel.Extra["shopid"],
                        payDataModel.OrderId,
                        payDataModel.openid);
                break;

            case "fail":
            case "cancel":
                //支付失败,跳转到购物车
                newUrl =
                    string.Format(
                        "../restaurant/diancai_shoppingCart.aspx?shopid={0}&openid={1}&wid={2}",
                        payDataModel.Extra["shopid"], payDataModel.openid, payDataModel.Extra["wid"]);
                break;
            }
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var payData = Request.QueryString["payData"];
            var ticket  = Request.QueryString["ticket"];

            if (!string.IsNullOrEmpty(payData) && !string.IsNullOrEmpty(ticket))
            {
                payData = EncryptionManager.AESDecrypt(payData, ticket);

                var payDataModel = JSONHelper.Deserialize <UnifiedOrderEntity>(payData);

                if (payDataModel != null)
                {
                    //赋值支付参数
                    wid          = payDataModel.wid;
                    body         = payDataModel.body;
                    payModuleID  = payDataModel.PayModuleID.ToString();
                    out_trade_no = payDataModel.out_trade_no;
                    total_fee    = payDataModel.total_fee;
                    openid       = payDataModel.openid;
                    OrderID      = payDataModel.OrderId;

                    PayComplete = string.Format("{0}{1}{2}&payStatus=",
                                                payDataModel.PayComplete,
                                                payDataModel.PayComplete.IndexOf("?", System.StringComparison.Ordinal) > 0 ? "&" : "?",
                                                Request.Url.Query.Substring(1));
                }
            }
            else
            {
                Response.Clear();
                Response.Write("不完整的参数");
            }
        }
Example #4
0
        public void AESEncryptTest()
        {
            var text     = Guid.NewGuid().ToString();
            var password = "******";
            var vi       = EncryptionManager.CreateIV();

            var en = EncryptionManager.AESEncrypt(text, password, vi);

            var cn = EncryptionManager.AESDecrypt(en, password, vi);

            Assert.IsTrue(string.Equals(text, cn));
        }
        public void AESDecrypt_ThrowsException_IncorrectCipherLength(string cipherText, string key)
        {
            EncryptionManager instance = new EncryptionManager();

            Assert.Throws <ArgumentException>(() => instance.AESDecrypt(key, cipherText));
        }
        public void AESDecrypt_ReturnsCorrectCipher_AnyTextAndKeyGiven(string cipherText, string key, string expResult)
        {
            EncryptionManager instance = new EncryptionManager();

            Assert.AreEqual(expResult, instance.AESDecrypt(key, cipherText));
        }
Example #7
0
 public void DESEncryptTest()
 {
     var beforeText = "x6i0CG/Pgcsj/cqDTk4FyrChEdSoml31MqFFM8bV5/LYhcefC2rlDlse0R4FywwHQtB5UL0PhEAJwgojXAYFehIb76NGv6kc8QIJfABCnnald56zwDCa6Tf8G5dUH%2B2ye3T329JZJo/Hf4mNUh4Lqwi2ZR37Qxh6ytLpGie1kMc2CpXC803WTThPbZtW8I7nV6vF3evtaITLGRYQdJZ%2BKxvbh6aB88O7eqg3bUxySEUkacmIcaBYb/%2BEjLxPAYSLfjFKWtyUI9fgBxFVUsEwaXWpayOb3dWEDJD6DyANTR9WP7AvNjV9XKBajALQmLCIpdPpWbp9Vj2Uz19CJlNRyk3U%2B4pc6gaM10h2ML08R3AEooxrVM3AQxT9SU91FO0RyAWt7O2ZxDB8QcExKF5Y4JA3psb9ZnShNilnR7ZTjAl9dQpzU4uKjigEEWlpwDmglFp2ZwGPRrsbz%2BcX75Js2p%2BdMkyBA5zDmvdZaXWIHAaXYQ%2BwvgGQy3NbZOqFpx3WaFhbgZvkr7x93LN/dQRhjyA0ZA9wNShFv%2BMaSGTgpuTFUc5rp5BkutBszS4EurF3";
     var ticket     = "HXR0TV8P28R64XFL";
     var afterText  = EncryptionManager.AESDecrypt(beforeText.Replace("%2B", "+"), "yidane", ticket);
 }
Example #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //读取支付参数
                var payData = Request.QueryString["payData"];
                var ticket  = Request.QueryString["ticket"];
                if (string.IsNullOrEmpty(payData) || string.IsNullOrEmpty(ticket))
                {
                    Response.Clear();
                    Response.Write("不完整的支付参数");
                    return;
                }

                //解析支付参数
                payData = EncryptionManager.AESDecrypt(payData, ticket);
                var payDataModel = JSONHelper.Deserialize <UnifiedOrderInfo>(payData);
                if (payDataModel == null)
                {
                    Response.Clear();
                    Response.Write("解析支付参数为空");
                    return;
                }

                //判断是否存在相同订单号
                //TODO:判断下单逻辑

                //统一下单
                string payErrorMessage;
                JsApiParameter = new UnifiedOrderService().UnifiedOrder(payDataModel, out payErrorMessage);
                if (JsApiParameter == null)
                {
                    Response.Clear();
                    Response.Write(payErrorMessage);
                    return;
                }

                //注册支付脚本
                var    jsApiTicketService = new JsApiTicketService();
                string jsApiTicketMessage;
                var    jsApiTicket = jsApiTicketService.GetJsApiTicket(payDataModel.AppId, out jsApiTicketMessage);
                if (jsApiTicket == null)
                {
                    Response.Clear();
                    Response.Write(jsApiTicketMessage);
                    return;
                }

                JsApiNonceStr  = JSSDKHelper.GetNoncestr();
                JsApiTimeStamp = JSSDKHelper.GetTimestamp();
                JsApiSingature = new JSSDKHelper().GetSignature(jsApiTicket.Ticket, JsApiNonceStr, JsApiTimeStamp, Request.Url.ToString());

                //支付初始化完成
                InitPayComplete = 1;
            }
            catch (Exception exception)
            {
                Response.Clear();
                Response.Write(exception.Message);
            }
        }