private void MontarPagamento() { try { var ambiente = IRLib.ConfiguracaoAdyen.Instancia.Chaves.Ativo.Valor && (Venda.FormaPagamento.BandeiraID != Convert.ToInt32(Sitef.enumBandeira.ValeCultura) && Venda.FormaPagamento.BandeiraID != Convert.ToInt32(Sitef.enumBandeira.EloCultura)) ? EstruturaPagamento.enumTipoPagamento.Adyen : EstruturaPagamento.enumTipoPagamento.TEF; try { if (Venda.Cartao.NumeroCartao.Length > 0) { Venda.Cartao.NumeroCartao = Criptografia.Crypto.Decriptografar(Venda.Cartao.NumeroCartao, ConfiguracaoCriptografia.Instancia.Chaves.Cartao.Valor); } if (Venda.Cartao.DataVencimento.Length > 0) { Venda.Cartao.DataVencimento = Criptografia.Crypto.Decriptografar(Venda.Cartao.DataVencimento, ConfiguracaoCriptografia.Instancia.Chaves.Data.Valor); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } oPagamento = new EstruturaPagamento() { TipoPagamento = ambiente, ClienteID = Venda.Cliente.ID, ClienteNome = Venda.Cliente.Nome, ClienteEmail = Venda.Cliente.Email, ValorTotal = Venda.ValorTotal, NumeroCartao = Venda.Cartao.NumeroCartao, DataVencimento = Venda.Cartao.DataVencimento, CodigoSeguranca = Venda.Cartao.CodigoSeguranca, NomeCartao = Venda.FormaPagamento.NomeCartao, Parcelas = Venda.FormaPagamento.Parcelas, SessionID = Guid.NewGuid().ToString(), IP = Venda.IP, Bandeira = Venda.FormaPagamento.BandeiraID.ToString(), FormaPagamentoID = Venda.FormaPagamento.ID, }; } catch (Exception ex) { throw ex; } }
public ProcessamentoPagamentos() { oPagamento = new EstruturaPagamento(); }
public static RetornoModel <string> EfetuaVendaSistemaComprarVIR(EstruturaPagamento oPagamento, EstruturaReservaInternet estruturaReservaInternet, string celular, CarrinhoLista oCarrinhoLista, CompraModel compra) { Carrinho oCarrinho = new Carrinho(); IRLib.Bilheteria bilheteria = new IRLib.Bilheteria(); string[] retornoVenda = new string[3]; string senha = string.Empty; string msgRetorno = "Ok"; try { int clienteID = compra.ClienteID; string SessionID = compra.SessionID; IRLib.Cliente oCliente = new IRLib.Cliente(); oCliente.Ler(clienteID); if (oCliente.Control.ID == 0) { return new RetornoModel <string>() { Sucesso = false, Retorno = senha, Mensagem = "Não foi possível localizar o seu cadastro, por favor, tente novamento." } } ; retornoVenda = bilheteria.VenderVIRWeb(oPagamento, oCarrinho.getValeIngressoID(clienteID, SessionID).ToArray(), SessionID, new List <EstruturaVirNomePresenteado>(), estruturaReservaInternet, celular, oCliente); //ErroIndefinido = -1, FalhaVenda = 0, Sucesso = 1, ClienteInexistente = 2, ReservaInexistente = 3, TaxaEntregaInexistente = 4, FormaPagamentoNaoCadastrada = 5, ReservasCanceladas = 6, switch (retornoVenda[0]) { case "1": //Sucesso oCarrinho.SetStatusCarrinho(clienteID, SessionID, "VV"); oCarrinhoLista.CarregarDadosVIRporClienteIDSessionID(clienteID, SessionID, CarrinhoLista.Status.VendidoEmail); senha = retornoVenda[1]; IngressoRapido.Lib.Entrega oEntrega = new IngressoRapido.Lib.Entrega(); EstruturaEntrega oEE = oEntrega.CarregarEstruturaPeloControleID(oPagamento.EntregaControleID); string formpagamento = string.Empty; if (oPagamento.TipoPagamento == EstruturaPagamento.enumTipoPagamento.Nenhum) { formpagamento = "Cortesia"; } else if (oPagamento.TipoPagamento == EstruturaPagamento.enumTipoPagamento.VIR) { formpagamento = "Vale Ingresso"; } else { formpagamento = oPagamento.BandeiraNome.ToString() + " - " + oPagamento.Parcelas + "X"; } try { if (!string.IsNullOrEmpty(oCliente.CNPJ.Valor)) { IRLib.ServicoEmail.EnviarVendaAprovadaVir(oCliente.NomeFantasia.Valor, oCliente.Email.Valor, retornoVenda[1], string.Empty, "Site", DateTime.Now.ToString(), "Site", formpagamento, string.Empty, oEE.Nome); } else { IRLib.ServicoEmail.EnviarVendaAprovadaVir(oCliente.Nome.Valor, oCliente.Email.Valor, retornoVenda[1], string.Empty, "Site", DateTime.Now.ToString(), "Site", formpagamento, string.Empty, oEE.Nome); } } catch { msgRetorno = "Sua compra foi efetuada com sucesso no entando o envio para o Email informado gerou um erro, por favor entre em contato com a Ingresso Rápido informando a senha de compra"; } oCarrinho.SetStatusCarrinho(clienteID, SessionID, "V"); return(new RetornoModel <string>() { Sucesso = true, Retorno = senha, Mensagem = msgRetorno }); case "0": // falha ao inserir registro na tVendaBilheteria return(new RetornoModel <string>() { Sucesso = false, Retorno = senha, Mensagem = "Falha ao efetuar o pedido. A venda não pôde ser gerada." }); case "2": // falha ao inserir registro na tVendaBilheteria return(new RetornoModel <string>() { Sucesso = false, Retorno = senha, Mensagem = "Cliente Inexistente. A venda não pôde ser gerada." }); case "3": return(new RetornoModel <string>() { Sucesso = false, Retorno = senha, Mensagem = "Reserva Inexistente. A venda não pôde ser gerada." }); case "4": return(new RetornoModel <string>() { Sucesso = false, Retorno = senha, Mensagem = "Taxa de Entrega Inexistente. A venda não pôde ser gerada." }); case "6": return(new RetornoModel <string>() { Sucesso = false, Retorno = senha, Mensagem = "Reservas Canceladas. A venda não pôde ser gerada." }); case "-1": return(new RetornoModel <string>() { Sucesso = false, Retorno = senha, Mensagem = retornoVenda[1] }); default: return(new RetornoModel <string>() { Sucesso = false, Retorno = senha, Mensagem = "Falha ao efetuar o pedido. Erro indefinido." }); } } catch (ApplicationException ex) { return(new RetornoModel <string> { Sucesso = false, Retorno = senha, Mensagem = ex.Message }); } }
public static RetornoModel <VendaRetornoModel> EfetuaVendaSistemaTEFCortesia(EstruturaPagamento oPagamento, string celular, CarrinhoLista oCarrinhoLista, CompraModel compra, CompraPagamentoModel compraPagamento) { Carrinho oCarrinho = new Carrinho(); IRLib.Bilheteria bilheteria = new IRLib.Bilheteria(); string[] retornoVenda = new string[4]; string retornoMSG = "Ok"; try { int clienteID = compra.ClienteID; string SessionID = compra.SessionID; List <EstruturaDonoIngresso> listaDonoIngresso = new List <EstruturaDonoIngresso>(); foreach (Carrinho carrinho in oCarrinhoLista.Where(c => c.isCota.Length > 0)) { listaDonoIngresso.Add(new EstruturaDonoIngresso() { CodigoPromocional = carrinho.CotaItem.CodigoPromocional, DonoID = carrinho.DonoID, CotaItemID = carrinho.CotaItemID, CotaItemIDAPS = carrinho.CotaItemIDAPS, CPF = carrinho.CotaItem.DonoCPF, IngressoID = carrinho.CotaItem.IngressoID, Nominal = carrinho.CotaItem.Nominal, UsarCPFResponsavel = false, }); } IRLib.Cliente oCliente = new IRLib.Cliente(); oCliente.Ler(clienteID); RetornoModel <EstruturaReservaInternet> reservaInternet = MontarEstruturaReserva(compraPagamento, compra); if (!reservaInternet.Sucesso) { return(new RetornoModel <VendaRetornoModel>() { Sucesso = false, Mensagem = reservaInternet.Mensagem }); } if (reservaInternet.Retorno.CaixaID == 0) { reservaInternet.Retorno.CaixaID = bilheteria.VerificaCaixaInternet( reservaInternet.Retorno.UsuarioID, reservaInternet.Retorno.LojaID); } retornoVenda = bilheteria.VenderWebCortesia(oPagamento, oCarrinho.IngressosTaxasCarrinho(clienteID, SessionID), SessionID, celular, listaDonoIngresso, reservaInternet.Retorno, oCarrinhoLista.TotalTaxaProcessamento(), oCliente, clienteID); VendaRetornoModel retorno = new VendaRetornoModel(); string tipoEntrega = string.Empty; bool eTicket = false; IRLib.Entrega entrega = new IRLib.Entrega(); if (oPagamento.EntregaControleID > 0) { tipoEntrega = entrega.BuscaTipo(oPagamento.EntregaControleID); eTicket = entrega.VerificaeTicket(oPagamento.EntregaControleID); } //ErroIndefinido = -1, FalhaVenda = 0, Sucesso = 1, ClienteInexistente = 2, ReservaInexistente = 3, TaxaEntregaInexistente = 4, FormaPagamentoNaoCadastrada = 5, ReservasCanceladas = 6, switch (retornoVenda[0]) { case "1": //Sucesso retorno.MsgCodigo = 1; if (retornoVenda.Length > 1) { retorno.Senha = retornoVenda[1]; } if (retornoVenda.Length > 2) { retorno.VendaBilheteriaID = Convert.ToInt32(retornoVenda[2]); } if (retornoVenda.Length > 3) { retorno.MsgCelular = retornoVenda[3]; } if (retornoVenda.Length > 4) { retorno.Risco = retornoVenda[4]; } retornoMSG = TratarEnvioEmailPagamento(oPagamento, oCarrinhoLista, oCliente, clienteID, SessionID, oCarrinho, eTicket, retornoVenda, tipoEntrega, retornoMSG, true); TratarEnvioNPS(oCliente); return(new RetornoModel <VendaRetornoModel>() { Sucesso = true, Mensagem = "OK", Retorno = retorno }); case "7": oCarrinho.SetStatusCarrinhoVV(clienteID, SessionID, "VV", Convert.ToInt64(retornoVenda[2])); if (retornoVenda[0] == "7") { retornoMSG = "Sua compra foi efetuada com sucesso, no entanto não foi possivel realizar a compra do Serviço de Seguro Mondial."; } retornoMSG = TratarEnvioEmailPagamento(oPagamento, oCarrinhoLista, oCliente, clienteID, SessionID, oCarrinho, eTicket, retornoVenda, tipoEntrega, retornoMSG); TratarEnvioNPS(oCliente); return(new RetornoModel <VendaRetornoModel>() { Sucesso = true, Mensagem = retornoMSG }); case "0": // falha ao inserir registro na tVendaBilheteria return(new RetornoModel <VendaRetornoModel>() { Sucesso = false, Mensagem = "Falha ao efetuar o pedido. A venda não pôde ser gerada." }); case "2": // falha ao inserir registro na tVendaBilheteria return(new RetornoModel <VendaRetornoModel>() { Sucesso = false, Mensagem = "Cliente Inexistente. A venda não pôde ser gerada." }); case "3": return(new RetornoModel <VendaRetornoModel>() { Sucesso = false, Mensagem = "Reserva Inexistente. A venda não pôde ser gerada." }); case "4": return(new RetornoModel <VendaRetornoModel>() { Sucesso = false, Mensagem = "Taxa de Entrega Inexistente. A venda não pôde ser gerada." }); case "6": return(new RetornoModel <VendaRetornoModel>() { Sucesso = false, Mensagem = "Reservas Canceladas. A venda não pôde ser gerada." }); default: return(new RetornoModel <VendaRetornoModel>() { Sucesso = false, Mensagem = retornoVenda[1] }); } } catch (ApplicationException ex) { LogUtil.Error(ex); return(new RetornoModel <VendaRetornoModel> { Sucesso = false, Mensagem = ex.Message }); } }
private static string TratarEnvioEmailPagamento(EstruturaPagamento oPagamento, CarrinhoLista oCarrinhoLista, Cliente oCliente, int clienteID, string SessionID, Carrinho oCarrinho, bool eTicket, string[] retornoVenda, string tipoEntrega, string retornoMSG, bool EntradaFranca = false) { try { string clienteNome = string.Empty; int vendaBilheteriaID = Convert.ToInt32(retornoVenda[2]); if (!string.IsNullOrEmpty(oCliente.CNPJ.Valor)) { clienteNome = oCliente.NomeFantasia.Valor; } else { clienteNome = oCliente.Nome.Valor; } if (!string.IsNullOrEmpty(oCliente.Email.Valor)) { var parser = new IngressoRapido.TemplateParser.Parser(); string formpagamento = string.Empty; if (oPagamento.TipoPagamento == EstruturaPagamento.enumTipoPagamento.Nenhum) { formpagamento = "Cortesia"; } else if (oPagamento.TipoPagamento == EstruturaPagamento.enumTipoPagamento.VIR) { formpagamento = "Vale Ingresso"; } else if (oPagamento.TipoPagamento == EstruturaPagamento.enumTipoPagamento.Milhas) { formpagamento = "Milhas Smiles"; } else { formpagamento = oPagamento.BandeiraNome.ToString() + " - " + oPagamento.Parcelas + "X"; } oCarrinhoLista.CarregarDadosPorClienteID(clienteID, SessionID, CarrinhoLista.Status.Reservado, 0); oCarrinho.SetStatusCarrinho(clienteID, SessionID, "V"); /*Os robôs são responsáveis por enviar os e-mails de eticket e tef*/ var oVendaBilheteria = new IRLib.VendaBilheteria(); var detalhesVenda = oVendaBilheteria.AcompanhamentoIngressos(vendaBilheteriaID); var email = new IRLib.EmailAccertify(); if (EntradaFranca && oPagamento.EntregaControleID == new IRLib.ConfigGerenciador().getEntregaControleIDMobileTicket()) { email.EnviarConfirmacaoCompraMobileTicket(clienteID, detalhesVenda); } else { email.EnviarCompraEmAnalise(clienteID, detalhesVenda); } } } catch (Exception ex) { LogUtil.Error(ex); retornoMSG = "Sua compra foi efetuada com sucesso, no entanto não foi possivel realizar o envio do email"; } return(retornoMSG); }
public static Parser VendaAprovada_RetiradaBilheteria(string nome, string email, string senhaPedido, string htmlPedido, string atendente, string dataVenda, string canal, string formasPagamento, EstruturaPagamento oPagamento, List <int> eventos) { Hashtable templateVars = new Hashtable(); templateVars.Add("Nome", nome); templateVars.Add("Email", email); templateVars.Add("SenhaPedido", senhaPedido); templateVars.Add("HtmlPedido", htmlPedido); templateVars.Add("Atendente", atendente); templateVars.Add("DataVenda", dataVenda); templateVars.Add("Canal", canal); templateVars.Add("FormasPagamento", formasPagamento); templateVars.Add("TipoTaxa", oPagamento.EntregaNome); Parser parser = new Parser(HttpContext.Current.Server.MapPath("~/MailTemplates/Novos_Templates/VendaRealizada_retirada.htm"), templateVars); return(parser); }
public static Parser VendaAprovada_Retirada(string nome, string email, string senhaPedido, string htmlPedido, string atendente, string dataVenda, string canal, string formasPagamento, EstruturaPagamento oPagamento, List <int> eventos) { PontoVenda pv = new PontoVenda(); pv.Carregar(oPagamento.PdvID); int diasEntrega = new IRLib.Entrega().MaiorDiasTriagemEntrega(oPagamento.EntregaControleID, eventos); Hashtable templateVars = new Hashtable(); templateVars.Add("Nome", nome); templateVars.Add("Email", email); templateVars.Add("SenhaPedido", senhaPedido); templateVars.Add("HtmlPedido", htmlPedido); templateVars.Add("Atendente", atendente); templateVars.Add("DataVenda", dataVenda); templateVars.Add("Canal", canal); templateVars.Add("FormasPagamento", formasPagamento); templateVars.Add("TipoTaxa", oPagamento.EntregaNome); templateVars.Add("PDVSelecionado", pv.Nome); templateVars.Add("Endereco", pv.Endereco + ", " + pv.Numero + " - " + pv.Compl); templateVars.Add("DataEntrega", DateTime.Now.AddDays(diasEntrega).ToString("dd/MM/yyyy")); Parser parser = new Parser(HttpContext.Current.Server.MapPath("~/MailTemplates/Novos_Templates/VendaRealizada_pontovenda.htm"), templateVars); return(parser); }
public static Parser VendaAprovada_EntregaAgendada(string nome, string email, string senhaPedido, string htmlPedido, string atendente, string dataVenda, string canal, string formasPagamento, EstruturaPagamento oPagamento, List <int> eventos) { EstruturaClienteEndereco retorno = new ClienteEndereco().LerEstrutura(oPagamento.EnderecoClienteID); Hashtable templateVars = new Hashtable(); templateVars.Add("Nome", nome); templateVars.Add("Email", email); templateVars.Add("SenhaPedido", senhaPedido); templateVars.Add("HtmlPedido", htmlPedido); templateVars.Add("Atendente", atendente); templateVars.Add("DataVenda", dataVenda); templateVars.Add("Canal", canal); templateVars.Add("FormasPagamento", formasPagamento); templateVars.Add("TipoTaxa", oPagamento.EntregaNome); templateVars.Add("Endereco", retorno.Endereco + ", " + retorno.Numero + " - " + retorno.Bairro + " / " + retorno.Cidade + " - " + retorno.Estado); templateVars.Add("DataEntrega", DateTime.ParseExact(oPagamento.DataSelecionada, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")); Parser parser = new Parser(HttpContext.Current.Server.MapPath("~/MailTemplates/Novos_Templates/VendaRealizada_motoboyagendado.htm"), templateVars); return(parser); }
public static Parser VendaAprovada_EntregaNormal(string nome, string email, string senhaPedido, string htmlPedido, string atendente, string dataVenda, string canal, string formasPagamento, EstruturaPagamento oPagamento, List <int> eventos) { EstruturaClienteEndereco retorno = new ClienteEndereco().LerEstrutura(oPagamento.EnderecoClienteID); int diasEntrega = 0; if (eventos != null) { diasEntrega = new IRLib.Entrega().MaiorDiasTriagemEntrega(oPagamento.EntregaControleID, eventos); } else { diasEntrega = new IRLib.Entrega().MaiorDiasTriagemEntregaVale(oPagamento.EntregaControleID); } Hashtable templateVars = new Hashtable(); templateVars.Add("Nome", nome); templateVars.Add("Email", email); templateVars.Add("SenhaPedido", senhaPedido); templateVars.Add("HtmlPedido", htmlPedido); templateVars.Add("Atendente", atendente); templateVars.Add("DataVenda", dataVenda); templateVars.Add("Canal", canal); templateVars.Add("FormasPagamento", formasPagamento); templateVars.Add("TipoTaxa", oPagamento.EntregaNome); templateVars.Add("Endereco", retorno.Endereco + ", " + retorno.Numero + " - " + retorno.Bairro + " / " + retorno.Cidade + " - " + retorno.Estado); templateVars.Add("DataEntrega", DateTime.Now.AddDays(diasEntrega).ToString("dd/MM/yyyy")); Parser parser; if (oPagamento.EntregaNome.Contains("Sedex")) { parser = new Parser(HttpContext.Current.Server.MapPath("~/MailTemplates/Novos_Templates/VendaRealizada_sedex.htm"), templateVars); } else { parser = new Parser(HttpContext.Current.Server.MapPath("~/MailTemplates/Novos_Templates/VendaRealizada_motoboy.htm"), templateVars); } return(parser); }
private void MontarPagamento() { try { EstruturaPagamento.enumTipoPagamento ambiente; if (ConfiguracaoAdyen.Instancia.Chaves.Ativo.Valor && Venda.FormaPagamento.NotaFiscal.Contains(AdyenStatic.Fields.NotaFiscal)) { ambiente = EstruturaPagamento.enumTipoPagamento.Adyen; } else if (Venda.FormaPagamento.BandeiraID == Convert.ToInt32(Cartao.enumBandeira.PayPal)) { ambiente = EstruturaPagamento.enumTipoPagamento.Paypal; } else { ambiente = EstruturaPagamento.enumTipoPagamento.TEF; } try { if (Venda.Cartao.NumeroCartao.Length > 0) { Venda.Cartao.NumeroCartao = Criptografia.Crypto.Decriptografar(Venda.Cartao.NumeroCartao, ConfiguracaoCriptografia.Instancia.Chaves.Cartao.Valor); } if (Venda.Cartao.DataVencimento.Length > 0) { Venda.Cartao.DataVencimento = Criptografia.Crypto.Decriptografar(Venda.Cartao.DataVencimento, ConfiguracaoCriptografia.Instancia.Chaves.Data.Valor); } } catch (Exception ex) { LogUtil.Error(string.Format("##HammerHead.MontarPagamento.CriptografiaCartao.EXCEPTION## VENDA: {0}, MSG: {1}", Venda.ID, ex.Message), ex); } oPagamento = new EstruturaPagamento { TipoPagamento = ambiente, ClienteID = Venda.Cliente.ID, ClienteNome = Venda.Cliente.Nome, ClienteEmail = Venda.Cliente.Email, ValorTotal = Venda.ValorTotal, NumeroCartao = Venda.Cartao.NumeroCartao, DataVencimento = Venda.Cartao.DataVencimento, CodigoSeguranca = Venda.Cartao.CodigoSeguranca, NomeCartao = Venda.FormaPagamento.NomeCartao, Parcelas = Venda.FormaPagamento.Parcelas, SessionID = Guid.NewGuid().ToString(), IP = Venda.IP, Bandeira = Venda.FormaPagamento.BandeiraID.ToString(), FormaPagamentoID = Venda.FormaPagamento.ID, FormaPagamentoOrigem = Venda.FormaPagamento.VendaBilheteriaFormaPagamentoIDOrigem }; if (ambiente == EstruturaPagamento.enumTipoPagamento.Adyen) { oPagamento.oAdyen.CodigoReferencia = Venda.FormaPagamento.CodigoResposta; } LogUtil.Debug(string.Format("##HammerHead.MontarPagamento.SUCCESS## VENDA: {0}, CLIENTE: {1}", Venda.ID, Venda.Cliente.ID)); } catch (Exception ex) { LogUtil.Error(string.Format("##HammerHead.MontarPagamento.EXCEPTION## VENDA: {0}, MSG: {1}", Venda.ID, ex.Message), ex); throw new Exception("Erro ao MontarPagamento: " + ex.Message); } }