public void TestCreateAndUpdate()
        {
            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            string plan_id = "pxs6fx3asdaa7xg3ray4";
            Subscription subscription = new Subscription();
            subscription.PlanId = plan_id;
            subscription.CardId = "kwkoqpg6fcvfse8k8mg2";
            subscription = openpayAPI.SubscriptionService.Create(customer_id, subscription);
            Assert.IsNotNull(subscription.Card);

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

            subscription.Card = card;
            subscription = openpayAPI.SubscriptionService.Update(customer_id, subscription);
            Assert.IsNotNull(subscription.Card);
            int cardLength = card.CardNumber.Length;
            Assert.AreEqual("510510XXXXXX5100", subscription.Card.CardNumber);

            Subscription subscriptionGet = openpayAPI.SubscriptionService.Get(customer_id, subscription.Id);
            Assert.AreEqual(subscription.TrialEndDate, subscriptionGet.TrialEndDate);
        }
Пример #2
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);
        }
Пример #3
0
        public void TestCard_CreateAsCustomer()
        {
            string customer_id = "adyytoegxm6boiusecxm";
            Card card = new Card();
            card.CardNumber = "4111111111111111";
            card.HolderName = "Juanito Pérez Nuñez";
            card.Cvv2 = "123";
            card.ExpirationMonth = "01";
            card.ExpirationYear = "17";
            card.DeviceSessionId = "120938475692htbssd";

            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);

            card = openpayAPI.CardService.Create(customer_id, card);
            Assert.IsNotNull(card.Id);
            openpayAPI.CardService.Delete(customer_id, card.Id);
        }
Пример #4
0
        public void TestCard_CreateAsMerchant()
        {
            Card card = new Card();
            card.CardNumber = "4111111111111111";
            card.HolderName = "Juanito Pérez Nuñez";
            card.Cvv2 = "123";
            card.ExpirationMonth = "01";
            card.ExpirationYear = "17";
            card.DeviceSessionId = "120938475692htbssd3";

            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);

            card = openpayAPI.CardService.Create(card);
            Assert.IsNotNull(card.Id);
            Assert.IsNotNull(card.CreationDate);
            Assert.IsNull(card.Cvv2);
            openpayAPI.CardService.Delete(card.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);
        }
Пример #6
0
        public void TestPayoutAsCustomer_CreateCard()
        {
            OpenpayAPI openpayAPI = new OpenpayAPI(Constants.API_KEY, Constants.MERCHANT_ID);
            Card card = new Card();
            card.CardNumber = "4111111111111111";
            card.BankCode = "002";
            card.HolderName = "Payout User";


            PayoutRequest request = new PayoutRequest();
            request.Method = "card";
            request.Card = card;
            request.Amount = 5.5m;
            request.Description = "Payout test";
            Payout payout = openpayAPI.PayoutService.Create(customer_id, request);
            Assert.IsNotNull(payout.Id);
            Assert.IsNotNull(payout.CreationDate);
            Assert.IsNotNull(payout.Card);
            Assert.IsNull(payout.BankAccount);

            Payout payoutGet = openpayAPI.PayoutService.Get(customer_id, payout.Id);
            Assert.AreEqual(payout.Amount, payoutGet.Amount);
        }
Пример #7
0
 public Card GetCardInfo()
 {
     Card card = new Card();
     card.CardNumber = "5555555555554444";
     card.HolderName = "Juanito Pérez Nuñez";
     card.Cvv2 = "123";
     card.ExpirationMonth = "01";
     card.ExpirationYear = "18";
     return card;
 }