public Stripe.StripeList <Stripe.Card> GetCards(string customerId) { Stripe.CardService service = new CardService(); Stripe.StripeList <Stripe.Card> cards = service.List(customerId); return(cards); }
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); }
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); } }
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); }
// GET: Users/Card public string Card() { var userId = Int32.Parse(HttpContext.Session.GetString("UserID")); var user = _context.Users.Find(userId); var customerId = user.CustomerId; StripeLib stripeLib = new StripeLib(); Stripe.StripeList <Stripe.Card> cards = stripeLib.GetCards(customerId); if (cards.Count() == 0) { return(null); } return(cards.First().Id); }
private async Task HandleCheckoutSessionCompleted(Session session) { var service = new SessionService(); var priceService = new Stripe.PriceService(); var priceOptions = new Stripe.PriceGetOptions { Expand = new List <string> { "product" } }; Stripe.StripeList <Stripe.LineItem> lineItems = service.ListLineItems(session.Id); var productIds = new List <string>(); var userId = ""; productIds.AddRange(lineItems.Select(item => { var price = priceService.Get(item.PriceId, priceOptions); userId = price.Product.Metadata["UserId"]; return(price.Product.Metadata["AppId"]); // Filter out shipping line item if it was included }).Where(item => !item.Equals("-1"))); await AddOrder(productIds, userId); }