コード例 #1
0
        public void CreateTransactionTest()
        {
            TransactionService target = new TransactionService();
            TransactionRequest request = new TransactionRequest()
            {
                Buyer = new Domain.Account.Customer()
                {
                    Address = new Domain.Account.Address()
                    {
                        address = "Rua teste teste",
                        City = "Cidade Modelo",
                        Complement = "Apto 123",
                        Neighborhood = "Bairro de Teste",
                        Number = "123",
                        State = StateEnum.MINAS_GERAIS,
                        ZipCode = "38408-266"
                    },
                    BirthDate = new DateTime(1986, 07, 21),
                    CellPhone = "3499265135",
                    CompanyName = "Empresa X",
                    Cnpj = "72139715000130",
                    Cpf = "85082236504",
                    Gender = GenderEnum.MALE,
                    IssueRgDate = new DateTime(2010, 06, 25),
                    Mail = "*****@*****.**",
                    Name = "Bruno Aparecido Capel Moretti",
                    OrganConsignorRg = "SSP",
                    Phone = "3432558584",
                    Rg = "13194030",
                    SearchToken = String.Empty,
                    StateConsignorRg = StateEnum.MINAS_GERAIS
                },
                PaymentMethod = new PaymentMethod(PaymentMethodEnum.BB_ONLINE_TRANSFER),
                Products = new List<Product>() { { new Product("1236456", "Produto de teste 1", 5, new Decimal(15.25), "Produto exemplo") } },
                SellerMail = "*****@*****.**",
                OrderId = "123456",
                Free = "Texto livre para o usuário...",
                Freight = new Decimal(10.50),
                FreightType = FreightTypeEnum.SEDEX,
                Discount = new Decimal(1.95),
                Addition = new Decimal(2.65),
                UrlReturn = "retorno.pagamentodigital.com.br",
                UrlNotification = "aviso.pagamentodigital.com.br",
                Installments = 1,
                Currency = CurrencyEnum.REAL,
                AcceptedContract = true,
                ViewedContract = true
            };

            OAuthRequestData oauth = new OAuthRequestData("437f7c3021a87ebf1cefb17be66e3fb72fa8dd51");

            TransactionResponse actual = null;
            try
            {
                actual = target.CreateTransaction(request, oauth);
                Assert.IsNotNull(actual);
            }
            catch (ServiceException ex)
            {
                throw ex;
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: payu-br/bcash-dotnet-sdk
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Iniciou processo para criar uma transação de teste...");

                TransactionService transactionService = new TransactionService();
                TransactionRequest transactionRequest = GenerateTransactionRequest();

                Console.WriteLine("Objeto de transação instanciado...");

                TransactionResponse transactionResponse = transactionService.CreateTransaction(
                    transactionRequest,
                    new OAuthRequestData(CONSUMER_KEY));

                Console.WriteLine("Chamada realizada com sucesso!!!");
                Console.WriteLine("Status: " + transactionResponse.Status + " - " + transactionResponse.DescriptionStatus);
                Console.WriteLine("cancellationCode:" + transactionResponse.cancellationCode);
            }
            catch (HttpClientException ex)
            {
                Console.WriteLine("Erro ao criar transação: " + ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            catch (ConnectionException ex)
            {
                Console.WriteLine("Erro ao criar transação: " + ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            catch (ServiceException ex)
            {
                Console.WriteLine("Erro ao criar transação: ");
                foreach (ResponseError error in ex.Errors.List)
                {
                    Console.WriteLine(error.ToString());
                }
            }
            finally
            {
                Console.WriteLine();
                Console.WriteLine("Aperte qualquer tecla para fechar...");
                Console.ReadKey();
            }
        }
コード例 #3
0
        public void CreateTransactionWithExtendedWarrantyTest()
        {
            List<SearchProduct> products = new List<SearchProduct>() {
                new SearchProduct("nokia", 1550.00),
                new SearchProduct("samsung", 10.00)
            };

            ExtendedWarrantyResponse response = searchExtendedWarranty(products);

            Assert.AreEqual<int>(response.code, 2);

            Dictionary<string, ResponseProducts> reponseProducts = response.productsByDescrition();

            List<Product> Products = new List<Product>();

            ResponseProducts nokia = null;
            reponseProducts.TryGetValue("nokia", out nokia);

            Assert.IsNotNull(nokia);

            ResponseProducts samsung = null;
            reponseProducts.TryGetValue("samsung", out samsung);

            Assert.IsNotNull(samsung);

            Products.Add(newProduct(nokia));

            Products.Add(newProduct(samsung));

            TransactionRequest transactionRequest = getTransactionRequest(Products);

            OAuthRequestData oauth = new OAuthRequestData("437f7c3021a87ebf1cefb17be66e3fb72fa8dd51");

            TransactionResponse actual = null;
            try
            {
                TransactionService target = new TransactionService();
                actual = target.CreateTransaction(transactionRequest, oauth);
                Assert.IsNotNull(actual);
            }
            catch (ServiceException ex)
            {
                throw ex;
            }
        }