public void CreateCreditCardRequest_ShouldReturnNewTransactionResponse()
        {
            CieloService cieloService = new CieloService();

            Customer customer = new Customer("John Doe");


            CreditCard creditCard = new CreditCard("0000.0000.0000.0001",
                                                   "John Doe",
                                                   new CardExpiration(2020, 9), "123", CardBrand.Visa);

            Payment payment = new Payment(PaymentType.CreditCard, 380.2m, 1, "", creditCard: creditCard);

            var transaction = new TransactionRequest("14421", customer, payment);

            var response = cieloService.CreateTransaction(transaction);

            response.Should().NotBeNull();
            response.Should().BeOfType <NewTransactionResponse>();
            response.Tid.Should().NotBeEmpty();
            response.PaymentId.Should().NotBeEmpty();
            response.MerchantOrderId.Should().NotBeEmpty();
            response.ProofOfSale.Should().NotBeEmpty();
            response.AuthorizationCode.Should().NotBeEmpty();
            response.Status.Should().BeOfType <Status>();
            response.ReturnCode.Should().BeOfType <ReturnCode>();
            response.ReturnMessage.Should().NotBeEmpty();
            response.AuthenticationUrl.Should().BeNullOrEmpty();
        }
Beispiel #2
0
        private void ExecuteRequest()
        {
            var watch = Stopwatch.StartNew();

            ConsoleHelper.WriteHeader("Checking a Transaction");

            CustomConfiguration configuration = new CustomConfiguration()
            {
                DefaultEndpoint = ConfigurationManager.AppSettings["cielo.endpoint.default"],
                QueryEndpoint   = ConfigurationManager.AppSettings["cielo.endpoint.query"],
                MerchantId      = ConfigurationManager.AppSettings["cielo.customer.id"],
                MerchantKey     = ConfigurationManager.AppSettings["cielo.customer.key"],
                ReturnUrl       = ConfigurationManager.AppSettings["cielo.return.url"],
            };

            CieloService cieloService = new CieloService(configuration);

            try
            {
                var response = cieloService.CheckTransaction(paymentId: Guid.Parse("1a2d178a-dc87-4627-92a2-b5d18ba076cd"));

                ConsoleHelper.WriteResult(response);
            }
            catch (ResponseException ex)
            {
                ConsoleHelper.WriteError(ex);
            }
            catch (Exception ex)
            {
                ConsoleHelper.WriteError(ex);
            }

            watch.Stop();
            ConsoleHelper.WriteFooter(watch.ElapsedMilliseconds);
        }
Beispiel #3
0
        private void ExecuteRequest()
        {
            var watch = Stopwatch.StartNew();

            ConsoleHelper.WriteHeader("Capturing a Full Transaction");

            CustomConfiguration configuration = new CustomConfiguration()
            {
                DefaultEndpoint = ConfigurationManager.AppSettings["cielo.endpoint.default"],
                QueryEndpoint   = ConfigurationManager.AppSettings["cielo.endpoint.query"],
                MerchantId      = ConfigurationManager.AppSettings["cielo.customer.id"],
                MerchantKey     = ConfigurationManager.AppSettings["cielo.customer.key"],
                ReturnUrl       = ConfigurationManager.AppSettings["cielo.return.url"],
            };

            CieloService cieloService = new CieloService(configuration);

            try
            {
                var response = cieloService.CaptureTransaction(Guid.Parse("55158bb3-2bb9-4e76-a92b-708b51245f4b"));

                ConsoleHelper.WriteResult(response);
            }
            catch (ResponseException ex)
            {
                ConsoleHelper.WriteError(ex);
            }
            catch (Exception ex)
            {
                ConsoleHelper.WriteError(ex);
            }

            watch.Stop();
            ConsoleHelper.WriteFooter(watch.ElapsedMilliseconds);
        }
Beispiel #4
0
        public override TransactionResponse Execute(bool validar = false)
        {
            CieloService        cieloService = new CieloService(base.Cielo.Configuration);
            TransactionResponse response     = cieloService.SearchTransaction(base.Cielo.Payment.PaymentId);

            return(response);
        }
        public void CheckTransaction_ShouldReturnCardResponse()
        {
            CieloService cieloService = new CieloService();

            Customer customer = new Customer("John Doe");


            CreditCard creditCard = new CreditCard("0000.0000.0000.0001",
                                                   "John Doe",
                                                   new CardExpiration(2020, 9), "123", CardBrand.Visa);

            Payment payment = new Payment(PaymentType.CreditCard, 380.2m, 1, "", creditCard: creditCard);

            var transaction = new TransactionRequest("14421", customer, payment);

            var transactionResponse = cieloService.CreateTransaction(transaction);

            var response = cieloService.CheckTransaction(paymentId: transactionResponse.PaymentId);

            response.Should().NotBeNull();
            response.Should().BeOfType <CheckTransactionResponse>();
            response.Customer.Name.Should().NotBeEmpty();
            response.Payment.Tid.Should().NotBeEmpty();
            response.Payment.AuthorizationCode.Should().NotBeEmpty();
            response.Payment.PaymentId.Should().NotBeEmpty();
            response.Payment.Status.Should().BeOfType <Status>();
        }
Beispiel #6
0
        public override TransactionResponse Execute(bool validar = false)
        {
            base.ValidarCard(saveCard: false);

            CieloService        cieloService = new CieloService(base.Cielo.Configuration);
            CreditCardRequest   request      = new CreditCardRequest(base.Cielo.Header.Name, base.Cielo.Card.CardNumber, base.Cielo.Card.Holder, new CardExpiration(base.Cielo.Card.YearExpired, base.Cielo.Card.MonthExpired), base.Cielo.Card.Brand);
            TransactionResponse response     = cieloService.SaveCard(request);

            return(response);
        }
        public void SaveCard_ShouldReturnCheckTransactionResponse()
        {
            CieloService cieloService = new CieloService();

            CreditCardRequest request = new CreditCardRequest("John Doe", "0000.0000.0000.0004", "John Doe", new CardExpiration(2020, 8), CardBrand.MasterCard);

            var response = cieloService.SaveCard(request);

            response.Should().NotBeNull();
            response.Should().BeOfType <CardResponse>();
            response.CardToken.Should().NotBeEmpty();
        }
Beispiel #8
0
        public override TransactionResponse Execute(bool validar = false)
        {
            CieloService        cieloService = new CieloService(base.Cielo.Configuration);
            TransactionResponse response     = cieloService.SearchCardBin(base.Cielo.Card.CardNumber);

            if (validar && !response.Card.Success)
            {
                throw new Exception("ERROR: " + response.Card.Provider);
            }

            return(response);
        }
Beispiel #9
0
        public override TransactionResponse Execute(bool validar = false)
        {
            base.ValidarPayment();

            CieloService        cieloService = new CieloService(base.Cielo.Configuration);
            TransactionResponse response     = cieloService.CaptureTransaction(base.Cielo.Payment.PaymentId);

            if (validar && !response.HttpResponse.Approved)
            {
                throw new Exception("TRANSAÇÃO NEGADA: " + response.HttpResponse.ReturnMessage);
            }

            return(response);
        }
        public override TransactionResponse Execute(bool validar = false)
        {
            base.ValidarPayment(validarMerchantOrderId: true, partial: true);

            CieloService        cieloService = new CieloService(base.Cielo.Configuration);
            TransactionResponse response     = cieloService.CancelTransaction(paymentId: base.Cielo.Payment.PaymentId, merchantOrderId: base.Cielo.Header.MerchantOrderId, amount: base.Cielo.Payment.Amount);

            if (validar && !response.HttpResponse.Voided)
            {
                throw new Exception("ERROR: " + response.HttpResponse.ReturnMessage);
            }

            return(response);
        }
Beispiel #11
0
        public override TransactionResponse Execute(bool validar = false)
        {
            base.ValidarPayment(partial: true);

            CieloService        cieloService = new CieloService(base.Cielo.Configuration);
            TransactionResponse response     = cieloService.CaptureTransaction(base.Cielo.Payment.PaymentId, base.Cielo.Payment.Amount);

            if (validar && !response.HttpResponse.Approved)
            {
                throw new Exception("ERROR: " + response.HttpResponse.ReturnMessage);
            }

            return(response);
        }
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            _cieloService = new CieloService();
            _randomOrderId = new Random().Next(11111, 9999999).ToString(CultureInfo.InvariantCulture);
            _configuration = new CustomCieloConfiguration
            {
                CurrencyId = "986",
                CustomerId = "1006993069",
                CustomerKey = "25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3",
                Language = Language.Portuguese,
                ReturnUrl = "http://localhost:5654/LojaBuyPageCart/Callback"
            };

            base.OnActionExecuting(filterContext);
        }
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            _cieloService = new CieloService();
            _randomOrderId = new Random().Next(11111, 9999999).ToString(CultureInfo.InvariantCulture);
            _configuration = new CustomCieloConfiguration
            {
                CurrencyId = "986",
                CustomerId = "1001734898",
                CustomerKey = "e84827130b9837473681c2787007da5914d6359947015a5cdb2b8843db0fa832",
                Language = Language.Portuguese,
                ReturnUrl = "http://localhost:5654/CieloBuyPageCart/Callback"
            };

            base.OnActionExecuting(filterContext);
        }
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            _cieloService = new CieloService();
            _randomOrderId = new Random().Next(11111, 9999999).ToString(CultureInfo.InvariantCulture);
            _configuration = new CustomCieloConfiguration
            {
                CurrencyId = "986",
                CustomerId = "1006993069",
                CustomerKey = "25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3",
                Language = Language.Portuguese,
                ReturnUrl = "http://localhost:5654/LojaBuyPageCart/Callback"
            };

            base.OnActionExecuting(filterContext);
        }
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            _cieloService  = new CieloService();
            _randomOrderId = new Random().Next(11111, 9999999).ToString(CultureInfo.InvariantCulture);
            _configuration = new CustomCieloConfiguration
            {
                CurrencyId  = "986",
                CustomerId  = "1001734898",
                CustomerKey = "e84827130b9837473681c2787007da5914d6359947015a5cdb2b8843db0fa832",
                Language    = Language.Portuguese,
                ReturnUrl   = "http://localhost:5654/CieloBuyPageCart/Callback"
            };

            base.OnActionExecuting(filterContext);
        }
Beispiel #16
0
        private void ExecuteRequest()
        {
            var watch = Stopwatch.StartNew();

            ConsoleHelper.WriteHeader("Creating a Transaction with Debit Card");

            CustomConfiguration configuration = new CustomConfiguration()
            {
                DefaultEndpoint = ConfigurationManager.AppSettings["cielo.endpoint.default"],
                QueryEndpoint   = ConfigurationManager.AppSettings["cielo.endpoint.query"],
                MerchantId      = ConfigurationManager.AppSettings["cielo.customer.id"],
                MerchantKey     = ConfigurationManager.AppSettings["cielo.customer.key"],
                ReturnUrl       = ConfigurationManager.AppSettings["cielo.return.url"],
            };

            CieloService cieloService = new CieloService(configuration);

            Customer customer = new Customer("John Doe");

            DebitCard debitCard = new DebitCard("0000.0000.0000.0001",
                                                "John Doe",
                                                new CardExpiration(2020, 9), "123", CardBrand.Visa);

            Payment payment = new Payment(PaymentType.DebitCard, 380.2m, 1, "", debitCard: debitCard, returnUrl: configuration.ReturnUrl);

            var transaction = new TransactionRequest("14421", customer, payment);

            try
            {
                var response = cieloService.CreateTransaction(transaction);

                ConsoleHelper.WriteResult(response);
            }
            catch (ResponseException ex)
            {
                ConsoleHelper.WriteError(ex);
            }
            catch (Exception ex)
            {
                ConsoleHelper.WriteError(ex);
            }

            watch.Stop();
            ConsoleHelper.WriteFooter(watch.ElapsedMilliseconds);
        }
Beispiel #17
0
        private void ExecuteRequest()
        {
            var watch = Stopwatch.StartNew();

            ConsoleHelper.WriteHeader("Creating a Transaction with Card Token");

            CustomConfiguration configuration = new CustomConfiguration()
            {
                DefaultEndpoint = ConfigurationManager.AppSettings["cielo.endpoint.default"],
                QueryEndpoint   = ConfigurationManager.AppSettings["cielo.endpoint.query"],
                MerchantId      = ConfigurationManager.AppSettings["cielo.customer.id"],
                MerchantKey     = ConfigurationManager.AppSettings["cielo.customer.key"],
                ReturnUrl       = ConfigurationManager.AppSettings["cielo.return.url"],
            };

            CieloService cieloService = new CieloService(configuration);

            Customer customer = new Customer("John Doe");

            CreditCard creditCard = new CreditCard("ea9b8398-e8bb-4e77-a865-66109fc4563e", "123", CardBrand.Visa);

            Payment payment = new Payment(PaymentType.CreditCard, 380.2m, 1, "", creditCard: creditCard);

            var transaction = new TransactionRequest("14421", customer, payment);

            try
            {
                var response = cieloService.CreateTransaction(transaction);

                ConsoleHelper.WriteResult(response);
            }
            catch (ResponseException ex)
            {
                ConsoleHelper.WriteError(ex);
            }
            catch (Exception ex)
            {
                ConsoleHelper.WriteError(ex);
            }

            watch.Stop();
            ConsoleHelper.WriteFooter(watch.ElapsedMilliseconds);
        }
        public override TransactionResponse Execute(bool validar = false)
        {
            base.ValidarCard();
            base.ValidarRulesPay();

            CieloService        cieloService = new CieloService(base.Cielo.Configuration);
            Customer            customer     = new Customer(base.Cielo.Header.Name);
            CreditCard          creditCard   = new CreditCard(base.Cielo.Card);
            Payment             payment      = new Payment(PaymentType.CreditCard, base.Cielo.Payment.Amount, base.Cielo.Card.Installments, base.Cielo.Payment.SoftDescriptor, creditCard: creditCard);
            TransactionRequest  transaction  = new TransactionRequest(base.Cielo.Header.MerchantOrderId, customer, payment);
            TransactionResponse response     = cieloService.CreateTransaction(transaction);

            if (validar && !response.HttpResponse.Approved)
            {
                throw new Exception("ERROR: " + response.HttpResponse.ReturnMessage);
            }

            return(response);
        }
Beispiel #19
0
        private void ExecuteRequest()
        {
            var watch = Stopwatch.StartNew();

            ConsoleHelper.WriteHeader("Creating a Eletronic Transfer");

            CustomConfiguration configuration = new CustomConfiguration()
            {
                DefaultEndpoint = ConfigurationManager.AppSettings["cielo.endpoint.default"],
                QueryEndpoint   = ConfigurationManager.AppSettings["cielo.endpoint.query"],
                MerchantId      = ConfigurationManager.AppSettings["cielo.customer.id"],
                MerchantKey     = ConfigurationManager.AppSettings["cielo.customer.key"],
                ReturnUrl       = ConfigurationManager.AppSettings["cielo.return.url"],
            };

            CieloService cieloService = new CieloService();

            Customer customer = new Customer("John Doe");

            Payment payment = new Payment(PaymentType.EletronicTransfer, 100.00m, EletronicTransferProvider.BancodoBrasil, "http://www.cielo.com.br/");

            var transaction = new TransactionRequest("14421", customer, payment);

            try
            {
                var response = cieloService.CreateEletronicTransfer(transaction);

                ConsoleHelper.WriteResult(response);
            }
            catch (ResponseException ex)
            {
                ConsoleHelper.WriteError(ex);
            }
            catch (Exception ex)
            {
                ConsoleHelper.WriteError(ex);
            }

            watch.Stop();
            ConsoleHelper.WriteFooter(watch.ElapsedMilliseconds);
        }
        public void CreateDebitCard_ShouldReturnNewTransactionResponse()
        {
            CustomConfiguration configuration = new CustomConfiguration()
            {
                DefaultEndpoint = ConfigurationManager.AppSettings["cielo.endpoint.default"],
                QueryEndpoint   = ConfigurationManager.AppSettings["cielo.endpoint.query"],
                MerchantId      = ConfigurationManager.AppSettings["cielo.customer.id"],
                MerchantKey     = ConfigurationManager.AppSettings["cielo.customer.key"],
                ReturnUrl       = "http://localhost" + ConfigurationManager.AppSettings["cielo.return.url"] + "/14421"
            };

            CieloService cieloService = new CieloService(configuration);

            Customer customer = new Customer("John Doe");


            DebitCard debitCard = new DebitCard("0000.0000.0000.0001",
                                                "John Doe",
                                                new CardExpiration(2020, 9), "123", CardBrand.Visa);

            Payment payment = new Payment(PaymentType.DebitCard, 380.2m, 1, "", debitCard: debitCard, returnUrl: configuration.ReturnUrl);

            var transaction = new TransactionRequest("14421", customer, payment);

            var response = cieloService.CreateTransaction(transaction);

            response.Should().NotBeNull();
            response.Should().BeOfType <NewTransactionResponse>();
            response.Tid.Should().NotBeEmpty();
            response.PaymentId.Should().NotBeEmpty();
            response.MerchantOrderId.Should().NotBeEmpty();
            response.ProofOfSale.Should().NotBeEmpty();
            response.AuthorizationCode.Should().BeNullOrEmpty();
            response.Status.Should().BeOfType <Status>();
            response.ReturnCode.Should().BeOfType <ReturnCode>();
            response.ReturnMessage.Should().BeNullOrEmpty();
            response.AuthenticationUrl.Should().NotBeNullOrEmpty();
        }
        public void CreateEletronicTransferRequest_ShouldReturnEletronicTransferResponse()
        {
            CieloService cieloService = new CieloService();

            Customer customer = new Customer("John Doe");

            Payment payment = new Payment(PaymentType.EletronicTransfer, 100.00m, EletronicTransferProvider.BancodoBrasil, "http://www.cielo.com.br/");

            var transaction = new TransactionRequest("14421", customer, payment);

            var response = cieloService.CreateEletronicTransfer(transaction);

            response.Should().NotBeNull();
            response.Should().BeOfType <EletronicTransferResponse>();
            response.MerchantOrderId.Should().NotBeEmpty();
            response.PaymentId.Should().NotBeEmpty();
            response.Url.Should().NotBeEmpty();
            response.Url.Should().MatchRegex(@"^http(s)?:\/\/([\w-]+.)+[\w-]+(\/[\w- .\/?%&=])?$");
            response.Amount.Should().Equals(10000);
            response.Status.Should().BeOfType <Status>();
            response.Provider.Should().BeOfType <EletronicTransferProvider>();
            response.Provider.Should().Be(EletronicTransferProvider.Simulado);
        }
Beispiel #22
0
        private void ExecuteRequest()
        {
            var watch = Stopwatch.StartNew();

            ConsoleHelper.WriteHeader("Saving a Card");

            CustomConfiguration configuration = new CustomConfiguration()
            {
                DefaultEndpoint = ConfigurationManager.AppSettings["cielo.endpoint.default"],
                QueryEndpoint   = ConfigurationManager.AppSettings["cielo.endpoint.query"],
                MerchantId      = ConfigurationManager.AppSettings["cielo.customer.id"],
                MerchantKey     = ConfigurationManager.AppSettings["cielo.customer.key"],
                ReturnUrl       = ConfigurationManager.AppSettings["cielo.return.url"],
            };

            CieloService cieloService = new CieloService(configuration);

            CreditCardRequest request = new CreditCardRequest("John Doe", "0000.0000.0000.0004", "John Doe", new CardExpiration(2020, 8), CardBrand.MasterCard);

            try
            {
                var response = cieloService.SaveCard(request);

                ConsoleHelper.WriteResult(response);
            }
            catch (ResponseException ex)
            {
                ConsoleHelper.WriteError(ex);
            }
            catch (Exception ex)
            {
                ConsoleHelper.WriteError(ex);
            }

            watch.Stop();
            ConsoleHelper.WriteFooter(watch.ElapsedMilliseconds);
        }
        public void CancelTransaction_GivenNoOrderId_ShouldThrowAnExceptionOfTypeArgumentNullException()
        {
            CieloService cieloService = new CieloService();

            cieloService.Invoking(c => c.CancelTransaction(merchantOrderId: "")).ShouldThrow <ArgumentNullException>();
        }
        public void CancelPartialTransaction_GivenFakeMerchantOrderId_ShouldThrowAnExceptionOfTypeResponseException()
        {
            CieloService cieloService = new CieloService();

            cieloService.Invoking(c => c.CancelTransaction(merchantOrderId: "123123", amount: 20m)).ShouldThrow <ResponseException>();
        }
        public void CheckTransaction_GivenNullPaymentId_ShouldThrowAnExceptionOfTypeArgumentNullException()
        {
            CieloService cieloService = new CieloService();

            cieloService.Invoking(c => c.CheckTransaction(paymentId: null)).ShouldThrow <ArgumentNullException>();
        }
        public void CapturePartialTransaction_GivenFakePaymentId_ShouldThrowAnExceptionOfTypeResponseException()
        {
            CieloService cieloService = new CieloService();

            cieloService.Invoking(c => c.CaptureTransaction(Guid.Parse("55158bb3-2bb9-4e76-a92b-708b51245f4b"), 20.00m)).ShouldThrow <ResponseException>();
        }