public ActionResult Index() { // create the model var model = new ModelPayboxTest(); model.BodyRequest = "VERSION=00104&DATEQ=12092013151651&TYPE=56&NUMQUESTION=15165151&SITE=1999888&RANG=99&CLE=1999888I&MONTANT=100&DEVISE=978&REFABONNE=" + Guid.NewGuid().ToString().Substring(0, 8) + "@test-licencetobill.com-9624a659&PORTEUR=1111222233334444&DATEVAL=0914&CVV=123&ACTIVITE=027&DIFFERE=000"; return View(model); }
public ActionResult Index(TypeUrlPaybox? type, string ip, string bodyRequest) { // create the model var model = new ModelPayboxTest { Type = type, Ip = ip }; // if we have a body if(!string.IsNullOrEmpty(bodyRequest) && type.HasValue) { // push the body into the model model.BodyRequest = bodyRequest; // compute the url model.Url = this.GetUrl(type.Value, ip); // start a timer var timer = Stopwatch.StartNew(); try { // HACK if(type.Value == TypeUrlPaybox.PppsPreprodPlus) ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; var response = RequestFluent.Create(model.Url) .Method(HttpVerbs.Post) .ContentType("application/x-www-form-urlencoded") .Send(bodyRequest); model.Status = response.StatusHttp; model.BodyResponse = response.GetBodyAsString(); } catch(Exception exc) { model.Status = HttpStatusCode.InternalServerError; model.BodyResponse = exc.ToString(); } finally { // stop the timer timer.Stop(); // store elapsed time model.ElapsedMilliseconds = (int)timer.ElapsedMilliseconds; } try { var responsePing = RequestFluent.Create(ConfigurationManager.AppSettings["TestPingUrl"] ?? "http://dev-ltb-demo.poweron.fr/Paybox/Ping") .Send(); model.IpOutgoing = responsePing.GetBodyAsString(); } catch(Exception exc) { model.IpOutgoing = "failure (" + exc.Message + ")"; } } // if no body else { model.BodyRequest = "VERSION=00104&DATEQ=12092013151651&TYPE=56&NUMQUESTION=15165151&SITE=1999888&RANG=99&CLE=1999888I&MONTANT=100&DEVISE=978&REFABONNE=" + Guid.NewGuid().ToString().Substring(0, 8) + "@test-licencetobill.com-9624a659&PORTEUR=1111222233334444&DATEVAL=0914&CVV=123&ACTIVITE=027&DIFFERE=000"; } return View(model); }