Пример #1
0
        public Transacao RealizarPagamento(Pedido pedido, Pagamento pagamento)
        {
            var apiKey        = _configManager.GetValue("apiKey");
            var encriptionKey = _configManager.GetValue("encriptionKey");

            var serviceKey  = _payPalGateway.GetPayPalServiceKey(apiKey, encriptionKey);
            var cardHashKey = _payPalGateway.GetCardHashKey(serviceKey, pagamento.NumeroCartao);

            var pagamentoResult = _payPalGateway.CommitTransaction(cardHashKey, pedido.Id.ToString(), pagamento.Valor);

            // TODO: O gateway de pagamentos que deve retornar o objeto transação
            var transacao = new Transacao
            {
                PedidoId    = pedido.Id,
                Total       = pedido.Valor,
                PagamentoId = pagamento.Id
            };

            if (pagamentoResult)
            {
                transacao.StatusTransacao = StatusTransacao.Pago;
                return(transacao);
            }

            transacao.StatusTransacao = StatusTransacao.Recusado;
            return(transacao);
        }
Пример #2
0
        public Transaction Pay(Order order, Payment payment)
        {
            var apiKey        = _configManager.GetValue("apiKey");
            var encryptionKey = _configManager.GetValue("encryptionKey");

            var serviceKey  = _payPalGateway.GetPayPalServiceKey(apiKey, encryptionKey);
            var cardHashKey = _payPalGateway.GetCardHashKey(serviceKey, payment.CardNumber);

            var result = _payPalGateway.CommitTransaction(cardHashKey, order.Id.ToString(), payment.Amount);

            // TODO: Here the Payment Gateway should return the transaction
            var transaction = new Transaction
            {
                OrderId   = order.Id,
                Total     = order.Total,
                PaymentId = payment.Id
            };

            if (result)
            {
                transaction.TransactionStatus = TransactionStatus.Paid;
                return(transaction);
            }

            transaction.TransactionStatus = TransactionStatus.Rejected;
            return(transaction);
        }
Пример #3
0
        public Transaction ExecutePayment(Order order, Payment payment)
        {
            var apiKey        = _configManager.GetValue("apiKey");
            var encriptionKey = _configManager.GetValue("encriptionKey");

            var serviceKey  = _payPalGateway.GetPayPalServiceKey(apiKey, encriptionKey);
            var cardHashKey = _payPalGateway.GetCardHashKey(serviceKey, payment.NumberCard);

            var pagamentoResult = _payPalGateway.CommitTransaction(cardHashKey, order.Id.ToString(), payment.Total);

            // TODO: O gateway de pagamentos que deve retornar o objeto transação
            var transacao = new Transaction
            {
                OrderId   = order.Id,
                Total     = order.Total,
                PaymentId = payment.Id
            };

            if (pagamentoResult)
            {
                transacao.StatusTransaction = StatusTransaction.Paid;
                return(transacao);
            }

            transacao.StatusTransaction = StatusTransaction.Refused;
            return(transacao);
        }
Пример #4
0
        public Transaction MakePayment(Order order, Payment payment)
        {
            var apiKey        = _configurationManger.GetValue("apiKey");
            var encriptionKey = _configurationManger.GetValue("encriptionKey");

            var serviceKey  = _payPalGateway.GetPayPalServiceKey(apiKey, encriptionKey);
            var cardHashKey = _payPalGateway.GetCardHashKey(serviceKey, payment.CardNumber);

            var paymentResult = _payPalGateway.CommitTransaction(cardHashKey, order.Id.ToString(), payment.Value);

            // TODO: Payment gateway must to return the transaction object
            var transaction = new Transaction
            {
                OrderId   = order.Id,
                Total     = order.Value,
                PaymentId = payment.Id
            };

            if (paymentResult)
            {
                transaction.StatusTransaction = StatusTransaction.Paid;
                return(transaction);
            }

            transaction.StatusTransaction = StatusTransaction.Rejected;
            return(transaction);
        }
        public bool MakePayment(Order order, Payment payment)
        {
            var apiKey        = _configurationManager.GetValue("apiKey");
            var encriptionKey = _configurationManager.GetValue("encriptionKey");

            var serviceKey  = _payPalGateway.GetPayPalServiceKey(apiKey, encriptionKey);
            var cardHashKey = _payPalGateway.GetCardHashKey(serviceKey, payment.CreditCard);

            return(_payPalGateway.CommitTransaction(cardHashKey, order.Id.ToString(), payment.Value));
        }
        private bool CommitPaypalTransaction(Order order, Payment payment)
        {
            var apiKey        = _payPalConfigurationManager.GetApiKey();
            var encriptionKey = _payPalConfigurationManager.GetEncriptionKey();
            var serviceKey    = _payPalGateway.GetPayPalServiceKey(apiKey, encriptionKey);
            var cardHashKey   = _payPalGateway.GetCardHashKey(serviceKey, payment.CardNumber);

            bool isPaid = _payPalGateway.CommitTransaction(cardHashKey, order.Id.ToString(), payment.TotalPrice);

            return(isPaid);
        }
        public bool RealizarPagamento(Pedido pedido, Pagamento pagamento)
        {
            var apiKey        = _configurationManager.GetValue("apiKey");
            var encriptionKey = _configurationManager.GetValue("encriptionKey");

            var serviceKey  = _payPalGateway.GetPayPalServiceKey(apiKey, encriptionKey);
            var cardHashKey = _payPalGateway.GetCardHashKey(serviceKey, pagamento.CartaoCredito);

            var result = _payPalGateway.CommitTransaction(cardHashKey, pedido.Id.ToString(), pagamento.Valor);

            return(result);
        }
Пример #8
0
        public bool MakePayment(Request request, Payment payment)
        {
            var apiKey        = _configManager.GetValue("apiKey");
            var encriptionKey = _configManager.GetValue("encriptionKey");

            var serviceKey  = _payPalGateway.GetPayPalServiceKey(apiKey, encriptionKey);
            var cardHashKey = _payPalGateway.GetCardHashKey(serviceKey, payment.CrediCard);

            var pagamentoResult = _payPalGateway.CommitTransaction(cardHashKey, request.Id.ToString(), payment.Amount);

            return(pagamentoResult);
        }
        public bool RealizarPagamento(Pedido pedido, Pagamento pagamento)
        {
            //faz varias coisas, depende do gateway...

            var apiKey        = configurationManager.GetValue("apiKey");
            var encriptionKey = configurationManager.GetValue("encriptionKey");

            var serviceKey  = payPalGateway.GetPayPalServiceKey(apiKey, encriptionKey);
            var cardHashKey = payPalGateway.GetCardHashKey(serviceKey, pagamento.CartaoCredito);

            var pagamentoResult = payPalGateway.CommitTransaction(cardHashKey, pedido.Id.ToString(), pagamento.Valor);

            return(pagamentoResult);
        }