示例#1
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>();
        }
示例#2
0
        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();
        }
示例#3
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);
        }
        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);
        }
示例#5
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);
        }
示例#6
0
        public ActionResult Checkout()
        {
            var order = new Order(_randomOrderId, 4700.00m, DateTime.Now, "Goku e GokuSSJ");

            //Crédito - A vista
            var paymentMethod = new PaymentMethod(CreditCard.MasterCard, PurchaseType.Credit);
            var options       = new CreateTransactionOptions(AuthorizationType.AuthorizeSkippingAuthentication, capture: true);

            //Crédito - Parcelado Loja
            //var paymentMethod = new PaymentMethod(CreditCard.MasterCard, PurchaseType.StoreInstallmentPayment, 5);
            //var options = new CreateTransactionOptions(AuthorizationType.AuthorizeSkippingAuthentication, capture: true);

            //Débito
            //var paymentMethod = new PaymentMethod(CreditCard.MasterCard, PurchaseType.Debit);
            //var options = new CreateTransactionOptions(AuthorizationType.AuthorizeAuthenticatedOrNot, capture: true);
            var createTransactionRequest       = new CreateTransactionRequest(order, paymentMethod, options, configuration: _configuration);
            CreateTransactionResponse response = _cieloService.CreateTransaction(createTransactionRequest);

            Session["tid"] = response.Tid;
            return(Redirect(response.AuthenticationUrl));
        }
示例#7
0
        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();
        }