/// <summary>
        /// Log all incoming text in a text file
        /// </summary>
        public string Index()
        {
            var path = Server.MapPath(string.Format("~/notification{0}.log", DateTime.Now.ToString("yyyy-MM-dd")));

            //check post values
            string notification = new StreamReader(Request.InputStream).ReadToEnd();

            //check get values
            string query = Request.Url.Query;

            string line = string.Format("[{0}] POST: {1} GET: {2}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), notification, query);

            if (System.IO.File.Exists(path))
            {
                string oldText = System.IO.File.ReadAllText(path);
                using (var sw = new StreamWriter(path, false))
                {
                    sw.WriteLine(line);
                    sw.Write(oldText);
                }
            }
            else
            {
                System.IO.File.WriteAllText(path, line);
            }


            //now stars the order processing
            //step 1: get the order from the MultiSafepay client
            var  transactionid  = Request["transactionid"];
            var  pm             = new PaymentModel();
            var  c              = new MultiSafepay.MultiSafepayClient(pm.ApiKey, apiUrl: pm.ApiUrls[0]);
            bool ordercompleted = false;

            var order = c.GetOrder(transactionid);

            if (order != null)
            {
                ordercompleted = order.Status == "completed";
            }


            if (ordercompleted)
            {
                //get our order
                var facade  = FacadeFactory.GetInstance().GetFacade <MSPFacade>();
                var orderdb = facade.GetById <MSPOrder>(transactionid);

                if (orderdb != null)
                {
                    orderdb.Status = MSPOrderStatus.Completed;
                    facade.Save();
                }
            }
            return("OK");
        }
        /// <summary>
        /// Log all incoming text in a text file
        /// </summary>
        public string Index()
        {
            var path = Server.MapPath(string.Format("~/notification{0}.log", DateTime.Now.ToString("yyyy-MM-dd")));

            //check post values
            string notification = new StreamReader(Request.InputStream).ReadToEnd();

            //check get values
            string query = Request.Url.Query;

            string line = string.Format("[{0}] POST: {1} GET: {2}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), notification, query);

            if (System.IO.File.Exists(path))
            {
                string oldText = System.IO.File.ReadAllText(path);
                using (var sw = new StreamWriter(path, false))
                {
                    sw.WriteLine(line);
                    sw.Write(oldText);
                }
            }
            else System.IO.File.WriteAllText(path, line);

            //now stars the order processing
            //step 1: get the order from the MultiSafepay client
            var transactionid = Request["transactionid"];
            var pm = new PaymentModel();
            var c = new MultiSafepay.MultiSafepayClient(pm.ApiKey, apiUrl: pm.ApiUrls[0]);
            bool ordercompleted = false;

            var order = c.GetOrder(transactionid);
            if(order != null)
                ordercompleted = order.Status == "completed";

            if(ordercompleted)
            {
                //get our order
                var facade = FacadeFactory.GetInstance().GetFacade<MSPFacade>();
                var orderdb = facade.GetById<MSPOrder>(transactionid);

                if (orderdb != null)
                {
                    orderdb.Status = MSPOrderStatus.Completed;
                    facade.Save();
                }

            }
            return "OK";
        }
示例#3
0
        public ActionResult Post(PaymentModel pm)
        {
            var ordermodel = CreateRedirectOrder(pm);
            var c          = new MultiSafepay.MultiSafepayClient(pm.ApiKey, apiUrl: pm.ApiUrl);

            try
            {
                var order = c.CreateOrder(ordermodel);
                pm.PaymentUrl = order.PaymentUrl;
            }
            catch (Exception exc)
            {
                while (exc != null)
                {
                    pm.Errors.Add(exc.Message);
                    exc = exc.InnerException;
                }
            }

            return(Json(pm));
        }
        public ActionResult Post(PaymentModel pm)
        {
            var ordermodel = CreateRedirectOrder(pm);
            var c = new MultiSafepay.MultiSafepayClient(pm.ApiKey, apiUrl: pm.ApiUrl);

            try
            {

                var order = c.CreateOrder(ordermodel);
                pm.PaymentUrl = order.PaymentUrl;

            }
            catch(Exception exc)
            {

                while (exc != null)
                {
                    pm.Errors.Add(exc.Message);
                    exc = exc.InnerException;
                }
            }

            return Json(pm);
        }