Пример #1
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);
        }
Пример #2
0
        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);
        }