Beispiel #1
0
        public void Pagar(EnumFormaPagamento formaPagamento)
        {
            if (this.IsPaga())
            {
                throw new Exception("A compra já está paga.");
            }

            var novo = new Pagamento(formaPagamento)
                {
                    Status = EnumStatusPagamento.Aprovado,
                    Valor = this.ValorTotal,
                    DataPagamento = DateTime.Now
                };

                this.Pagamentos.Add(novo);
        }
Beispiel #2
0
        public void PagarCompra(long idCompra, EnumFormaPagamento formaPagamento)
        {
            if (formaPagamento == EnumFormaPagamento.NaoDefinida)
            {
                throw new Exception("Forma de pagamento não definida.");
            }

            ICompraService compraService = typeof (ICompraService).Fabricar();
            var compra = compraService.BuscarPorId(idCompra);

            if (formaPagamento == EnumFormaPagamento.PayPal)
            {
                using (var pagamentoServiceClient = new PagamentoWServiceClient())
                {
                    pagamentoServiceClient.Open();
                    if (pagamentoServiceClient.Pagar(compra.ValorTotal))
                    {
                        compraService.PagarCompra(compra, formaPagamento);
                    }
                }
            }
            else
            {

                using (var client = new ControladorPagamentoServiceClient())
                {
                    client.Open();

                    Juntos.WcfServiceApp.wsProxy.Pagamento pagto = new Juntos.WcfServiceApp.wsProxy.Pagamento();
                    pagto.Codigo = idCompra;
                    pagto.DataPagamento = DateTime.Now;
                    pagto.FormaPagamento = FormaPagamento.PagSeguro;
                    pagto.Valor = compra.ValorTotal;

                    client.PaymentRequest(pagto);

                    pagto = client.GetPaymentResult(pagto.Codigo);

                    if (pagto.Status==StatusPagamento.Aprovado)
                    {
                        compraService.PagarCompra(compra, formaPagamento);
                    }

               }
            }
        }
Beispiel #3
0
        private void CancelarPagamentoPendente(EnumFormaPagamento formaPagamento)
        {
            var novo = new Pagamento(formaPagamento)
            {
                Status = EnumStatusPagamento.Cancelado,
                Valor = this.ValorTotal,
                DataPagamento = DateTime.Now
            };

            this.Pagamentos.Add(novo);
        }
Beispiel #4
0
        public void RejeitarPagamento(EnumFormaPagamento formaPagamento)
        {
            var novo = new Pagamento(formaPagamento)
            {
                Status = EnumStatusPagamento.Rejeitado,
                Valor = this.ValorTotal,
                DataPagamento = DateTime.Now
            };

            this.Pagamentos.Add(novo);
        }
Beispiel #5
0
 public Pagamento(EnumFormaPagamento formaPagamento)
 {
     this.FormaPagamento = formaPagamento;
 }