public void TestCustomer_CreateAndDeleteWithAddress()
        {
            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            Customer customer = new Customer();
            customer.Name = "Net Client";
            customer.LastName = "C#";
            customer.Email = "*****@*****.**";
            customer.Address = new Address();
            customer.Address.Line1 = "line 1";
            customer.Address.PostalCode = "12355";
            customer.Address.City = "Queretaro";
            customer.Address.CountryCode = "MX";
            customer.Address.State = "Queretaro";

            customer = openpayAPI.CustomerService.Create(customer);
            Assert.IsNotNull(customer);
            Assert.IsNotNull(customer.Address);
            Assert.IsFalse(String.IsNullOrEmpty(customer.Id));
            Assert.AreEqual("Net Client", customer.Name);

            openpayAPI.CustomerService.Delete(customer.Id);

            try
            {
                openpayAPI.CustomerService.Get(customer.Id);
                Assert.Fail("No deberia existir");
            }
            catch (OpenpayException e)
            {
                Assert.IsNotNull(e.Description);
            }
        }
        public void TestCustomer_CreateAndDelete()
        {
            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            Customer customer = new Customer();
            customer.Name = "Net Client";
            customer.Email = "*****@*****.**";

            customer = openpayAPI.CustomerService.Create(customer);
            Assert.IsNotNull(customer);
            Assert.IsNotNull(customer.Store);
            Assert.IsFalse(String.IsNullOrEmpty(customer.Id));
            openpayAPI.CustomerService.Delete(customer.Id);
        }
        public void TestChargeToMerchantAndGetByOrderId()
        {
            Random random = new Random();
            ChargeRequest request = new ChargeRequest();
            request.Method = "card";
            request.Card = GetCardInfo();
            request.OrderId = random.Next(0, 10000000).ToString();
            request.Description = "Testing from .Net with new card";
            request.Amount = new Decimal(9.99);

            Customer customer = new Customer();
            customer.Name = "Openpay";
            customer.LastName = "Test";
            customer.PhoneNumber = "1234567890";
            customer.Email = "*****@*****.**";

            request.Customer = customer;

            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            Charge charge = openpayAPI.ChargeService.Create(request);
            Assert.IsNotNull(charge);

            SearchParams search = new SearchParams();
            search.OrderId = request.OrderId;
            List<Charge> charges = openpayAPI.ChargeService.List(search);
            Assert.AreEqual(1, charges.Count);
            Assert.AreEqual(charge.Id, charges[0].Id);
        }
        public void TestChargeToMerchantWithPointsBig()
        {
            ChargeRequest request = new ChargeRequest();
            request.Method = "card";
            request.Card = GetCardInfo();
            request.Description = "Testing from .Net with new card";
            request.Amount = new Decimal(29.99);
            request.UseCardPoints = true;

            Customer customer = new Customer();
            customer.Name = "Openpay";
            customer.LastName = "Test";
            customer.PhoneNumber = "1234567890";
            customer.Email = "*****@*****.**";

            request.Customer = customer;

            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            Charge charge = openpayAPI.ChargeService.Create(request);
            Assert.IsNotNull(charge);
            Assert.IsNotNull(charge.Id);
            Assert.IsNotNull(charge.CardPoints);
            Assert.AreEqual(charge.CardPoints.Amount, new Decimal(22.5));

            Charge charge2 = openpayAPI.ChargeService.Get(charge.Id);
            Assert.IsNotNull(charge2);
            Assert.IsNotNull(charge2.CardPoints);
            Assert.AreEqual(charge.Id, charge2.Id);
            Assert.AreEqual(charge.Amount, charge2.Amount);
            Assert.AreEqual(charge2.CardPoints.Amount, new Decimal(22.5));
        }