Example #1
0
        public void TestCreateOrder()
        {
            Moip.Models.OrderRequest orderRequest = Helpers.RequestsCreator.createOrderRequest();

            Moip.Models.OrderResponse orderResponse = controller.CreateOrder(orderRequest);

            Assert.NotNull(orderResponse.Id, "Id should not be null");
            Assert.AreEqual("my_own_id", orderResponse.OwnId, "Should match exactly (string literal match)");
            Assert.AreEqual("Bicicleta Specialized Tarmac 26 Shimano Alivio", orderResponse.Items[0].Product, "Should match exactly (string literal match)");
            Assert.AreEqual(1, orderResponse.Items[0].Quantity, "Should match exactly (string literal match)");
            Assert.AreEqual("uma linda bicicleta", orderResponse.Items[0].Detail, "Should match exactly (string literal match)");
            Assert.AreEqual(2000, orderResponse.Items[0].Price, "Should match exactly (string literal match)");
            Assert.AreEqual("BRL", orderResponse.Amount.Currency, "Should match exactly (string literal match)");
            Assert.AreEqual("Fulano de Tal", orderResponse.Customer.Fullname, "Should match exactly (string literal match)");
            Assert.AreEqual("OFulanoDeTal", orderResponse.Customer.OwnId, "Should match exactly (string literal match)");
            Assert.AreEqual("1990-01-01", orderResponse.Customer.BirthDate, "Should match exactly (string literal match)");
            Assert.AreEqual("*****@*****.**", orderResponse.Customer.Email, "Should match exactly (string literal match)");
            Assert.AreEqual("Rua test", orderResponse.ShippingAddress.Street, "Should match exactly (string literal match)");
            Assert.AreEqual("123", orderResponse.ShippingAddress.StreetNumber, "Should match exactly (string literal match)");
            Assert.AreEqual("Ap test", orderResponse.ShippingAddress.Complement, "Should match exactly (string literal match)");
            Assert.AreEqual("Bairro test", orderResponse.ShippingAddress.District, "Should match exactly (string literal match)");
            Assert.AreEqual("TestCity", orderResponse.ShippingAddress.City, "Should match exactly (string literal match)");
            Assert.AreEqual("SP", orderResponse.ShippingAddress.State, "Should match exactly (string literal match)");
            Assert.AreEqual("BRA", orderResponse.ShippingAddress.Country, "Should match exactly (string literal match)");
            Assert.AreEqual("01234000", orderResponse.ShippingAddress.ZipCode, "Should match exactly (string literal match)");
            Assert.AreEqual("55", orderResponse.Customer.Phone.CountryCode, "Should match exactly (string literal match)");
            Assert.AreEqual("11", orderResponse.Customer.Phone.AreaCode, "Should match exactly (string literal match)");
            Assert.AreEqual("66778899", orderResponse.Customer.Phone.Number, "Should match exactly (string literal match)");
            Assert.AreEqual("CPF", orderResponse.Customer.TaxDocument.Type, "Should match exactly (string literal match)");
            Assert.AreEqual("22222222222", orderResponse.Customer.TaxDocument.Number, "Should match exactly (string literal match)");
            Assert.AreEqual(1500, orderResponse.Amount.Subtotals.Shipping, "Should match exactly (string literal match)");
            Assert.AreEqual(20, orderResponse.Amount.Subtotals.Addition, "Should match exactly (string literal match)");
            Assert.AreEqual(10, orderResponse.Amount.Subtotals.Discount, "Should match exactly (string literal match)");
        }
Example #2
0
        public void TestOrderWithReceiversRequest()
        {
            Moip.Models.OrderRequest orderRequest = Helpers.RequestsCreator.createOrderWithReceiversRequest();

            string orderRequestJson = Moip.Utilities.APIHelper.JsonSerialize(orderRequest);

            string expectedOrderRequestJson = Helpers.FileReader.readJsonFile(@"Order\order_with_receivers.json");

            Assert.AreEqual(expectedOrderRequestJson, orderRequestJson,
                            "Order request body should match exactly (string literal match)");
        }
        public static Moip.Models.MultiorderRequest CreateMultiorderRequest()
        {
            Moip.Models.TaxDocument taxDocument = new Moip.Models.TaxDocument
            {
                Type   = "CPF",
                Number = "22222222222"
            };

            Moip.Models.Phone phone = new Moip.Models.Phone
            {
                CountryCode = "55",
                AreaCode    = "11",
                Number      = "66778899"
            };

            Moip.Models.ShippingAddress shippingAddress = new Moip.Models.ShippingAddress
            {
                Street       = "Rua test",
                StreetNumber = "123",
                Complement   = "Ap test",
                District     = "Bairro test",
                City         = "TestCity",
                State        = "SP",
                Country      = "BRA",
                ZipCode      = "01234000"
            };

            Moip.Models.CustomerRequest customerRequest = new Moip.Models.CustomerRequest
            {
                Fullname        = "Fulano de Tal",
                OwnId           = "OFulanoDeTal",
                BirthDate       = "1990-01-01",
                Email           = "*****@*****.**",
                Phone           = phone,
                ShippingAddress = shippingAddress,
                TaxDocument     = taxDocument
            };


            Moip.Models.SubtotalsRequest subtotalsRequest = new Moip.Models.SubtotalsRequest
            {
                Shipping = 1500,
                Addition = 20,
                Discount = 10
            };

            Moip.Models.AmountOrderRequest amountRequest = new Moip.Models.AmountOrderRequest
            {
                Currency  = "BRL",
                Subtotals = subtotalsRequest
            };

            Moip.Models.Item itemsRequest = new Moip.Models.Item
            {
                Product  = "Bicicleta Specialized Tarmac 26 Shimano Alivio",
                Quantity = 1,
                Detail   = "uma linda bicicleta",
                Price    = 2000
            };

            List <Moip.Models.Item> itemsRequestList = new List <Moip.Models.Item>
            {
                itemsRequest
            };

            Moip.Models.MoipAccountReceiverRequest moipAccountReceiver1 = new Moip.Models.MoipAccountReceiverRequest
            {
                Id = "MPA-14AC21F09CAE"
            };

            Moip.Models.AmountReceiverRequest amountReceiver1 = new Moip.Models.AmountReceiverRequest
            {
                Percentual = 50
            };

            Moip.Models.ReceiverRequest receiver1 = new Moip.Models.ReceiverRequest
            {
                MoipAccount = moipAccountReceiver1,
                Type        = "PRIMARY",
                Amount      = amountReceiver1
            };

            Moip.Models.MoipAccountReceiverRequest moipAccountReceiver2 = new Moip.Models.MoipAccountReceiverRequest
            {
                Id = "MPA-B0D880F21EF1"
            };

            Moip.Models.AmountReceiverRequest amountReceiver2 = new Moip.Models.AmountReceiverRequest
            {
                Percentual = 50
            };

            Moip.Models.ReceiverRequest receiver2 = new Moip.Models.ReceiverRequest
            {
                MoipAccount = moipAccountReceiver2,
                Type        = "SECONDARY",
                Amount      = amountReceiver2,
                FeePayor    = true
            };

            List <Moip.Models.ReceiverRequest> receiverList = new List <Moip.Models.ReceiverRequest>
            {
                receiver1,
                receiver2
            };

            Moip.Models.OrderRequest orderRequest1 = new Moip.Models.OrderRequest
            {
                OwnId     = "my_own_id",
                Amount    = amountRequest,
                Items     = itemsRequestList,
                Customer  = customerRequest,
                Receivers = receiverList
            };

            Moip.Models.CustomerRequest customerRequest2 = new Moip.Models.CustomerRequest
            {
                Fullname        = "Outro Nome Teste",
                OwnId           = "OFulanoDeTal",
                BirthDate       = "1990-01-01",
                Email           = "*****@*****.**",
                Phone           = phone,
                ShippingAddress = shippingAddress,
                TaxDocument     = taxDocument
            };

            Moip.Models.OrderRequest orderRequest2 = new Moip.Models.OrderRequest
            {
                OwnId     = "my_own_id2",
                Amount    = amountRequest,
                Items     = itemsRequestList,
                Customer  = customerRequest2,
                Receivers = receiverList
            };

            List <Moip.Models.OrderRequest> orderList = new List <Moip.Models.OrderRequest>();

            orderList.Add(orderRequest1);
            orderList.Add(orderRequest2);

            Moip.Models.MultiorderRequest multiOrderRequest = new Moip.Models.MultiorderRequest
            {
                OwnId  = "my_own_multi_order_id",
                Orders = orderList
            };


            return(multiOrderRequest);
        }
        public static Moip.Models.OrderRequest createOrderRequest()
        {
            Moip.Models.TaxDocument taxDocument = new Moip.Models.TaxDocument
            {
                Type   = "CPF",
                Number = "22222222222"
            };

            Moip.Models.Phone phone = new Moip.Models.Phone
            {
                CountryCode = "55",
                AreaCode    = "11",
                Number      = "66778899"
            };

            Moip.Models.ShippingAddress shippingAddress = new Moip.Models.ShippingAddress
            {
                Street       = "Rua test",
                StreetNumber = "123",
                Complement   = "Ap test",
                District     = "Bairro test",
                City         = "TestCity",
                State        = "SP",
                Country      = "BRA",
                ZipCode      = "01234000"
            };

            Moip.Models.CustomerRequest customerRequest = new Moip.Models.CustomerRequest
            {
                Fullname        = "Fulano de Tal",
                OwnId           = "OFulanoDeTal",
                BirthDate       = "1990-01-01",
                Email           = "*****@*****.**",
                Phone           = phone,
                ShippingAddress = shippingAddress,
                TaxDocument     = taxDocument
            };

            Moip.Models.SubtotalsRequest subtotalsRequest = new Moip.Models.SubtotalsRequest
            {
                Shipping = 1500,
                Addition = 20,
                Discount = 10
            };


            Moip.Models.AmountOrderRequest amountRequest = new Moip.Models.AmountOrderRequest
            {
                Currency  = "BRL",
                Subtotals = subtotalsRequest
            };

            Moip.Models.Item itemsRequest = new Moip.Models.Item
            {
                Product  = "Bicicleta Specialized Tarmac 26 Shimano Alivio",
                Quantity = 1,
                Detail   = "uma linda bicicleta",
                Price    = 2000
            };

            List <Moip.Models.Item> itemsRequestList = new List <Moip.Models.Item>
            {
                itemsRequest
            };

            Moip.Models.OrderRequest orderRequest = new Moip.Models.OrderRequest
            {
                OwnId    = "my_own_id",
                Amount   = amountRequest,
                Items    = itemsRequestList,
                Customer = customerRequest,
            };

            return(orderRequest);
        }