Example #1
0
        void pay_status()
        {
            string orderno = Request.QueryString["orderno"] ?? string.Empty;

            if (string.IsNullOrEmpty(orderno))
            {
                return;
            }

            var service = new Services.OrderService();
            var status  = service.QueryOrderStatus(orderno);

            CallbackData(new { code = 0, status = status, orderno = orderno });
        }
Example #2
0
        void callbackUrlDo(string orderno)
        {
            var service = new Services.OrderService();

            var info = service.GetOrderInfo(orderno);

            if (info == null)
            {
                return;
            }

            var status = service.QueryOrderStatus(orderno);

            var config = Config.GetProjectConfig(info.Project);

            if (config == null)
            {
                return;
            }

            if (!string.IsNullOrEmpty(config.CallbackURL))
            {
                Uri calluri = null;

                if (Uri.TryCreate(config.CallbackURL, UriKind.Absolute, out calluri))
                {
                    var nvc = new NameValueCollection();
                    nvc["orderno"] = orderno;
                    nvc["amount"]  = info.Amount.ToString();
                    nvc["status"]  = status == Services.OrderStatus.Succ ? "succ" : "unkonwn";
                    nvc["sign"]    = GetCallbackUrlDoSign(config, nvc);


                    using (var wc = new System.Net.WebClient())
                    {
                        byte[] data = wc.UploadValues(config.CallbackURL, "POST", nvc);

                        string result = null;

                        if (data != null)
                        {
                            result = System.Text.Encoding.GetEncoding("utf-8").GetString(data);
                        }

                        service.UpdateCallbackData(orderno, result ?? string.Empty);
                    }
                }
            }
        }