Пример #1
0
        public void TestListSubscriptions()
        {
            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            Plan plan = new Plan();
            plan.Name = "Tv";
            plan.Amount = 89.99m;
            plan.RepeatEvery = 1;
            plan.RepeatUnit = "month";
            plan.StatusAfterRetry = "unpaid";
            plan.TrialDays = 0;
            plan = openpayAPI.PlanService.Create(plan);

            Card card = new Card();
            card.CardNumber = "345678000000007";
            card.HolderName = "Juanito Pérez Nuñez";
            card.Cvv2 = "1234";
            card.ExpirationMonth = "01";
            card.ExpirationYear = "17";

            Subscription subscription = new Subscription();
            subscription.PlanId = plan.Id;
            subscription.Card = card;
            subscription = openpayAPI.SubscriptionService.Create(customer_id, subscription);

            List<Subscription> subscriptions = openpayAPI.PlanService.Subscriptions(plan.Id);
            Assert.AreEqual(1, subscriptions.Count);

            openpayAPI.SubscriptionService.Delete(customer_id, subscription.Id);
            openpayAPI.PlanService.Delete(plan.Id);
        }
Пример #2
0
        public void TestCreateGeDelete()
        {
            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            Plan plan = new Plan();
            plan.Name = "Tv";
            plan.Amount = 99.99m;
            plan.RepeatEvery = 1;
            plan.RepeatUnit = "month";
            plan.StatusAfterRetry = "unpaid";
            plan.TrialDays = 0;
            Plan planCreated = openpayAPI.PlanService.Create(plan);
            Assert.IsNotNull(planCreated.Id);
            Assert.IsNotNull(planCreated.CreationDate);
            Assert.AreEqual("active", planCreated.Status);

            Plan planGet = openpayAPI.PlanService.Get(planCreated.Id);
            Assert.AreEqual(planCreated.Name, planGet.Name);

            openpayAPI.PlanService.Delete(planCreated.Id);
        }
        public void TestCreateSubscription()
        {
            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            Plan plan = new Plan();
            plan.Name = "Tv";
            plan.Amount = 89.99m;
            plan.RepeatEvery = 1;
            plan.RepeatUnit = "month";
            plan.StatusAfterRetry = "unpaid";
            plan.TrialDays = 0;
            plan = openpayAPI.PlanService.Create(plan);

            Card card = new Card();
            card.CardNumber = "4242424242424242";
            card.HolderName = "Juanito Pérez Nuñez";
            card.Cvv2 = "123";
            card.ExpirationMonth = "01";
            card.ExpirationYear = "17";

            Subscription subscription = new Subscription();
            subscription.PlanId = plan.Id;
            subscription.Card = card;
            subscription = openpayAPI.SubscriptionService.Create(customer_id, subscription);
            Assert.IsNotNull(subscription.Id);
            Assert.IsNotNull(subscription.CreationDate);
            Assert.AreEqual(false, subscription.CancelAtPeriodEnd);
            Assert.IsNotNull(subscription.ChargeDate);
            Assert.AreEqual(1, subscription.CurrentPeriod);
            Assert.IsNotNull(subscription.PeriodEndDate);
            //Assert.IsNull(subscription.TrialEndDate);
            Assert.IsNotNull(subscription.PlanId);
            Assert.IsNotNull(subscription.Status);
            Assert.AreEqual(customer_id, subscription.CustomerId);
            Assert.IsNotNull(subscription.PlanId);
            Assert.IsNotNull(subscription.Card);

            openpayAPI.SubscriptionService.Delete(customer_id, subscription.Id);
            openpayAPI.PlanService.Delete(plan.Id);
        }