public IntegracaoPagamentoService(bool isProduction, GatewayPagamento gatewayPagamento) { if (gatewayPagamento == GatewayPagamento.IUGU) { _integracaoPagamento = new IUGUService(isProduction); } }
//Persistir o objecto e salvar na base de dados private bool inserir(GatewayPagamento OGatewayPagamento) { OGatewayPagamento.setDefaultInsertValues(); db.GatewayPagamento.Add(OGatewayPagamento); db.SaveChanges(); return(OGatewayPagamento.id > 0); }
//Verificar se deve-se atualizar um registro existente ou criar um novo public bool salvar(GatewayPagamento OGatewayPagamento) { if (OGatewayPagamento.id == 0) { return(this.inserir(OGatewayPagamento)); } return(this.atualizar(OGatewayPagamento)); }
private void CobrarCartao(DetalhesPagamento detalhesDoPagamento, Carrinho carrinho) { var gatewayPagamento = new GatewayPagamento(); gatewayPagamento.credencial = "bla"; gatewayPagamento.MumeroCartao = detalhesDoPagamento.MumeroCartao; gatewayPagamento.MesExpiracao = detalhesDoPagamento.MesExpiracao; gatewayPagamento.AnoExpiracao = detalhesDoPagamento.AnoExpiracao; gatewayPagamento.NomeNoCartao = detalhesDoPagamento.NomeNoCartao; gatewayPagamento.Valor = carrinho.ValorTotal; gatewayPagamento.Cobrar(); }
private async Task AutorizarPagamento(CartaoDto cartaoDto, double valor) { var pagamentoSem = new PagamentoRequestDto { Cartao = cartaoDto, Valor = valor }; var gatewayPagamento = new GatewayPagamento(_configuration); var autorizarPagamento = await gatewayPagamento.AutorizarPagamento(pagamentoSem); if (autorizarPagamento == null || !autorizarPagamento.Estado.Equals("APROVADO")) { throw new Exception(); } }
//Persistir o objecto e atualizar informações private bool atualizar(GatewayPagamento OGatewayPagamento) { OGatewayPagamento.setDefaultUpdateValues(); //Localizar existentes no banco GatewayPagamento dbGateway = this.carregar(OGatewayPagamento.id); var GatewayEntry = db.Entry(dbGateway); GatewayEntry.CurrentValues.SetValues(OGatewayPagamento); GatewayEntry.ignoreFields(); db.SaveChanges(); return(OGatewayPagamento.id > 0); }