public async Task <int> ImportSubscriptionItem(SubscriptionItem item)
        {
            _logger.LogInformation(GetLogMessage("{SubscriptionItem}"), item.Id);

            var existingItem = _itemRepository.Queryable().FirstOrDefault(x => x.Id == item.Id);

            if (existingItem == null)
            {
                existingItem = new StripeSubscriptionItem()
                {
                    ObjectState = ObjectState.Added,
                    Id          = item.Id
                };
            }
            else
            {
                existingItem.ObjectState = ObjectState.Modified;
            }

            existingItem.SubscriptionId = item.Subscription;
            existingItem.PlanId         = item.Plan.Id;
            existingItem.IsDeleted      = item.Deleted.GetValueOrDefault();
            existingItem.Quantity       = item.Quantity;

            return(await Task.FromResult(_itemRepository.InsertOrUpdateGraph(existingItem, true)));
        }
Esempio n. 2
0
                public BillingSubscriptionItem(StripeSubscriptionItem item)
                {
                    if (item.Plan != null)
                    {
                        Name     = item.Plan.Nickname;
                        Amount   = item.Plan.Amount / 100M;
                        Interval = item.Plan.Interval;
                    }

                    Quantity = item.Quantity;
                }