Exemplo n.º 1
0
        public void MPIPN_MerchantOrderNotification_MustBeOk()
        {
            SDK.CleanConfiguration();
            SDK.AccessToken = Environment.GetEnvironmentVariable("ACCESS_TOKEN");

            var merchantOrder =
                new MerchantOrder
            {
                Payer = new MercadoPago.DataStructures.MerchantOrder.Payer
                {
                    Email = "*****@*****.**"
                },
                Items = new List <Item>
                {
                    new Item
                    {
                        Description = "Test Ipn",
                        Quantity    = 1,
                        UnitPrice   = 10m
                    }
                }
            };

            merchantOrder.Save();

            Ipn.HandleNotification(Ipn.MerchantOrder, merchantOrder.Id, onPaymentReceived: null, onMerchantOrderReceived: m =>
            {
                Assert.AreEqual(m.Id, merchantOrder.Id);
                Assert.AreEqual(m.Items.Count, merchantOrder.Items.Count);
                Assert.AreEqual(m.Items[0].UnitPrice, merchantOrder.Items[0].UnitPrice);
                Assert.AreEqual(m.Items[0].Description, merchantOrder.Items[0].Description);
                Assert.Pass();
            });

            Assert.Fail();
        }
Exemplo n.º 2
0
        public void MerchantOrder_CreateShouldBeOk()
        {
            SDK.CleanConfiguration();
            SDK.SetBaseUrl("https://api.mercadopago.com");

            Dictionary <string, string> config = new Dictionary <string, string>();

            config.Add("clientSecret", Environment.GetEnvironmentVariable("CLIENT_SECRET"));
            config.Add("clientId", Environment.GetEnvironmentVariable("CLIENT_ID"));
            SDK.SetConfiguration(config);

            MerchantOrder merchantOrderInternal = new MerchantOrder();

            try
            {
                var result = merchantOrderInternal.Save();
            }
            catch (MPException mpException)
            {
                Assert.Fail();
            }

            Assert.Pass();
        }