Esempio n. 1
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);
        }
Esempio n. 2
0
        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>();
        }
        public ActionResult Callback()
        {
            var checkTransactionRequest = new CheckTransactionRequest((string)Session["tid"], _configuration);
            var response = _cieloService.CheckTransaction(checkTransactionRequest);

            ViewBag.Status = response.Status.ToString();

            return(View());
        }