Пример #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);
        }
Пример #2
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();
        }
Пример #3
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();
        }