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

            Payment payment = new Payment()
            {
                TransactionAmount = 50000f,
                Token             = CardHelper.SingleUseCardToken(Environment.GetEnvironmentVariable("PUBLIC_KEY"), "approved"),
                Description       = "Pago de seguro",
                PaymentMethodId   = "master",
                Installments      = 1,
                Payer             = new DataStructures.Payment.Payer
                {
                    Email = "*****@*****.**"
                }
            };

            payment.Save();

            var resource = MercadoPagoIPN.Manage <Payment>(MercadoPagoIPN.Topic.Payment, payment.Id.ToString());

            Assert.IsTrue(resource.GetType().IsSubclassOf(typeof(MercadoPagoBase)));
            Assert.AreEqual(payment.Id, ((Payment)resource).Id);
            Assert.AreEqual(payment.Description, ((Payment)resource).Description);
            Assert.AreEqual(payment.PaymentMethodId, ((Payment)resource).PaymentMethodId);
        }
Exemplo n.º 2
0
        public void MPIPN_GetTypeShouldReturnATypeObject()
        {
            Type type = MercadoPagoIPN.GetType(MercadoPagoIPN.Topic.Payment);

            if (type != null)
            {
                Assert.Pass();
            }
            else
            {
                Assert.Fail();
            }
        }
Exemplo n.º 3
0
        public void MPIPN_MustThrowException_ClassNotExtendsFromMPBase()
        {
            try
            {
                MercadoPagoIPN.Manage <Payment>("MercadoPagoCore.DataStructures.Customer.City", "1234567");
            }
            catch (MercadoPagoException exception)
            {
                Assert.AreEqual("City does not extend from MercadoPagoBase", exception.Message);
                return;
            }

            Assert.Fail();
        }
Exemplo n.º 4
0
        public void MPIPN_MustThrowException_TopicParameterEmpty()
        {
            try
            {
                MercadoPagoIPN.Manage <Payment>(null, "id");
            }
            catch (MercadoPagoException exception)
            {
                Assert.AreEqual("Topic and Id can not be null in the IPN request.", exception.Message);
                return;
            }

            Assert.Fail();
        }
Exemplo n.º 5
0
        public void MPIPN_GetTypeShouldReturnNotNullValue()
        {
            Type type = MercadoPagoIPN.GetType(MercadoPagoIPN.Topic.Payment);

            Assert.IsNotNull(type);
        }
Exemplo n.º 6
0
        public void MPIPN_GetTypeShouldReturnNull()
        {
            Type type = MercadoPagoIPN.GetType("MercadoPagoCore.Resources.PatmentMeans");

            Assert.IsNull(type);
        }
Exemplo n.º 7
0
        public void MPIPN_GetTypeShouldFindTheRightClassType()
        {
            Type type = MercadoPagoIPN.GetType(MercadoPagoIPN.Topic.Payment);

            Assert.IsTrue(typeof(Payment) == type);
        }