예제 #1
0
        public bool HasSubscription(string customerId)
        {
            var subscriptionService = new Stripe.SubscriptionService();

            Stripe.StripeList <Stripe.Subscription> response = subscriptionService.List(new Stripe.SubscriptionListOptions
            {
                CustomerId = customerId
            });

            return(response.Count() >= 1);
        }
예제 #2
0
        public void DeleteSubscriptions(string customerId)
        {
            var subscriptionService = new Stripe.SubscriptionService();

            Stripe.StripeList <Stripe.Subscription> subscriptions = subscriptionService.List(new Stripe.SubscriptionListOptions
            {
                CustomerId = customerId
            });

            foreach (Stripe.Subscription subscription in subscriptions)
            {
                subscriptionService.Cancel(subscription.Id, null);
            }
        }
예제 #3
0
        public string GetSubscription(string customerId)
        {
            var subscriptionService = new Stripe.SubscriptionService();

            Stripe.StripeList <Stripe.Subscription> subscriptions = subscriptionService.List(new Stripe.SubscriptionListOptions
            {
                CustomerId = customerId
            });

            if (subscriptions.Count() == 0)
            {
                return("N/A");
            }

            return(subscriptions.First().Plan.Nickname);
        }
예제 #4
0
        public async Task <int> ImportSubscriptions(int limit)
        {
            _logger.LogInformation(GetLogMessage("Limit: {limit}"), limit);

            var svc = new StripeSubscriptionService();

            var subscriptions = svc.List(new SubscriptionListOptions()
            {
                Limit = limit
            });
            var totals = 0;

            foreach (var customer in subscriptions)
            {
                var returnValue = await PullSubscription(customer);

                totals += returnValue;
            }

            return(totals);
        }