public ActionResult Checkout() { this.Musico = new MusicoVM(this.BaseUsuario); var pagamento = new Pagamento(this.BaseUsuario, 30.00m).GerarPagamento(); NameValueCollection dados = new NameValueCollection { { "reference", pagamento.REF }, { "itemDescription1", "Conta Premium - Nosso Show" }, { "itemAmount1", pagamento.Valor.ToString().Replace(",", ".") }, { "senderName", this.Musico.Nome }, { "senderEmail", this.Musico.Email.Split('@')[0].ToString() + "@sandbox.pagseguro.com.br" } }; if (false) //if (!string.IsNullOrEmpty(this.Musico.Telefone)) { string telefone = new string(this.Musico.Telefone.Where(c => char.IsDigit(c)).ToArray()); dados.Add("senderAreaCode", telefone.Substring(0, 2)); dados.Add("senderPhone", telefone.Substring(2, telefone.Count() - 2)); } string url = PagSeguro.Checkout(dados); return(Redirect(url)); }
public string Post([FromBody] Mensalidade value) { try { Mensalidade oMensalidade = new Mensalidade(); oMensalidade = oMensalidade.ToMensalidade(oMensalidade.ObtemById(value.id)[0]); Aluno oAluno = new Aluno(); oAluno = oAluno.ToAluno(oAluno.ObtemUnico(Convert.ToInt32(oMensalidade.id_aluno))); Instituicao oInstituicao = new Instituicao(); oInstituicao = oInstituicao.GetByUser(Convert.ToInt32(oAluno.id_usuario)); PagSeguroPagamento oPagSeguroPagamento = new PagSeguro().Checkout(oMensalidade, oAluno, oInstituicao); oPagSeguroPagamento.idMensalidade = oMensalidade.id; oPagSeguroPagamento.Criar(oPagSeguroPagamento.code, oPagSeguroPagamento.date, Convert.ToInt32(oPagSeguroPagamento.idMensalidade)); return(oPagSeguroPagamento.code); } catch (Exception e) { ErroHandler.Log("PagSeguro_CheckoutController", e, "POST", ""); throw e; } }
public ActionResult Premium(string t) { var xml = PagSeguro.GetXmlTransacao(t); if (xml != null) { Pagamento p = Pagamento.AtualizarPagamento(xml); return(View(p)); } else { return(Redirect("/inicio/buscar/")); } }
//public ActionResult FinalizarVenda(int? idCliente, int[] ListaProdutos, int[] ListaQuantidade) //{ // var result = new JsonResult(); // var total = 0.0; // var pagSeguro = new PagSeguro(); // var item = new ItemVenda(); // var prod = new ItemVenda(); // var vendedor = _session.Query<Vendedor>().OrderByDescending(x => x.Id).FirstOrDefault(); // var cliente = _session.Query<RenderUser>().Where(x => x.Id == idCliente).FirstOrDefault(); // var listProduto = _session.Query<Produto>().Where(x => ListaProdutos.Contains(x.Id)).ToList(); // var cont = 0; // var itens = ""; // foreach (Produto i in listProduto) // { // total += (float)i.Valor * ListaQuantidade[cont]; // itens = itens + i.Nome + " "; // cont++; // } // DateTime data = DateTime.Now; // var venda = new Venda(); // venda.IdCliente = cliente.Id; // venda.IdVendedor = vendedor.Id; // venda.ValorTotal = (float)total; // venda.DataVenda = data; // cont = 0; // foreach (Produto i in listProduto) // { // var itemVenda = new ItemVenda(); // itemVenda.Quantidade = ListaQuantidade[cont]; // itemVenda.IdProduto = i.Id; // itemVenda.IdVenda = venda.Id; // _session.Save(itemVenda); // cont++; // } // int refe; // try // { // refe = _session.Query<Venda>().OrderByDescending(x => x.Referencia).FirstOrDefault().Referencia + 1; // venda.Referencia = refe; // } // catch // { // venda.Referencia = 1; // } // _session.Save(venda); // var url = pagSeguro.CheckOut(cliente.Pessoa.Nome, itens, venda.ValorTotal.ToString(), cont.ToString(), cliente.Telefone, venda.Referencia.ToString()); // venda.url = url; // result.Data = venda; // return Json(result, JsonRequestBehavior.AllowGet); //} //public ActionResult BuscarCliente(string cpf) //{ // var result = new JsonResult(); // var resp = _session.Query<RenderUser>().Where(x => x.CPF.ToLower() == cpf.ToLower()).FirstOrDefault(); // result.Data = resp; // return Json(result, JsonRequestBehavior.AllowGet); //} public ActionResult ConfirmarEstorno(int idVenda) { var pagSeguro = new PagSeguro(); var result = new JsonResult(); var venda = _session.Query <Venda>().Where(x => x.Id == idVenda).FirstOrDefault(); venda.IdVendedor = 0; venda.IdCliente = 0; var code = pagSeguro.ConsultarTransacao(venda.Referencia); pagSeguro.Estornar(code); _session.Save(venda); result.Data = venda; return(Json(result, JsonRequestBehavior.AllowGet)); }
public void TestMethod1() { BuildWebHost(); using (var db = new P3DContext()) { var model = new PedidoModel() { Upload = db.Uploads.FindAll().ToList()[0], Checkout = new CheckoutModel() }; model.valor_total = 200; model.Checkout.FillDemoAddrData(); model.Checkout.nome = "Joao Bosco"; model.Checkout.email = "*****@*****.**"; PagSeguro.GenerateToken(model); } }
// HtmlDocument doc; public ActionResult Index() { var a = new NetCoders(); var b = new PagSeguro(); // b.CheckOut(); //Session.Add("Usuario",new Usuario()); // a.CarregaPosts(); //string titulo; //using (WebClient client = new WebClient()) //{ // var html = client.htt("https://www.zoom.com.br/notebook?q=notebook&resultsperpage=72"); // doc.LoadHtml(html); //} ////Titulo //HtmlNode no = doc.DocumentNode.SelectSingleNode("//div[@id='dvTitulo']/h1[@class='titdestaque']"); //titulo = no.InnerText; return(View()); }
public ActionResult Xml(string id) { return(this.Content(PagSeguro.GetXmlTransacao(id).InnerXml, "text/xml")); }