public virtual StripeSubscription Update(string subscriptionId, StripeSubscriptionUpdateOptions updateOptions, StripeRequestOptions requestOptions = null) { var url = string.Format(Urls.Subscriptions + "/{0}", subscriptionId); return(Mapper <StripeSubscription> .MapFromJson( Requestor.PostString(this.ApplyAllParameters(updateOptions, url, false), SetupRequestOptions(requestOptions)) )); }
public virtual StripeSubscription Update(string customerId, string subscriptionId, StripeSubscriptionUpdateOptions updateOptions) { var url = string.Format(Urls.Subscriptions + "/{1}", customerId, subscriptionId); url = ParameterBuilder.ApplyAllParameters(updateOptions, url); var response = Requestor.PostString(url, ApiKey); return Mapper.MapFromJson<StripeSubscription>(response); }
public virtual StripeSubscription Update(string customerId, string subscriptionId, StripeSubscriptionUpdateOptions updateOptions, StripeRequestOptions requestOptions = null) { var url = string.Format(Urls.Subscriptions + "/{1}", customerId, subscriptionId); return Mapper<StripeSubscription>.MapFromJson( Requestor.PostString(this.ApplyAllParameters(updateOptions, url, false), SetupRequestOptions(requestOptions)) ); }
public virtual async Task <StripeSubscription> UpdateAsync(string customerId, string subscriptionId, StripeSubscriptionUpdateOptions updateOptions, StripeRequestOptions requestOptions = null) { var url = string.Format(Urls.Subscriptions + "/{1}", customerId, subscriptionId); return(Mapper <StripeSubscription> .MapFromJson( await Requestor.PostStringAsync(this.ApplyAllParameters(updateOptions, url, false), SetupRequestOptions(requestOptions)) )); }
public virtual async Task <StripeSubscription> UpdateAsync(string subscriptionId, StripeSubscriptionUpdateOptions updateOptions, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) { var url = string.Format(Urls.Subscriptions + "/{0}", subscriptionId); return(Mapper <StripeSubscription> .MapFromJson( await Requestor.PostStringAsync(this.ApplyAllParameters(updateOptions, url, false), SetupRequestOptions(requestOptions), cancellationToken) )); }
public virtual Task <StripeSubscription> UpdateAsync(string customerId, string subscriptionId, StripeSubscriptionUpdateOptions updateOptions, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) { return(this.UpdateAsync(subscriptionId, updateOptions, requestOptions, cancellationToken)); }
public virtual StripeSubscription Update(string customerId, string subscriptionId, StripeSubscriptionUpdateOptions updateOptions, StripeRequestOptions requestOptions = null) { return(this.Update(subscriptionId, updateOptions, requestOptions)); }
public virtual StripeSubscription Update(string customerId, string subscriptionId, StripeSubscriptionUpdateOptions updateOptions, StripeRequestOptions requestOptions = null) { requestOptions = SetupRequestOptions(requestOptions); var url = string.Format(Urls.Subscriptions + "/{1}", customerId, subscriptionId); url = this.ApplyAllParameters(updateOptions, url, false); var response = Requestor.PostString(url, requestOptions); return(Mapper <StripeSubscription> .MapFromJson(response)); }
public async Task<ActionResult> DowngradePlan() { await Task.Run(() => { var cust = getCustomer(); if (cust != null) // downgrade { // retrieve customer var customerService = new StripeCustomerService(); StripeCustomer currentCustomer = customerService.Get(cust.StripeCustomerID); // change plan StripeSubscriptionService subService = new StripeSubscriptionService(); StripeSubscriptionUpdateOptions updateOptions = new StripeSubscriptionUpdateOptions(); updateOptions.PlanId = "standard"; updateOptions.TrialEnd = currentTime; // no free days allowed when downgrading var myUpdateSuscription = subService.Update(currentCustomer.Id, cust.StripeSubscriptionID, updateOptions); // record changes in db StripeCustomers newRecord = new StripeCustomers(); newRecord.StripeCustomerID = myUpdateSuscription.CustomerId; newRecord.CustomerName = User.Identity.Name; newRecord.StripeSubscriptionID = cust.StripeSubscriptionID; newRecord.SubscriptionType = "standard"; newRecord.TrialValidUntil = currentTime; newRecord.HasSubscription = true; newRecord.StartDate = currentTime; newRecord.Interval = "Monthly"; db.StripeCustomers.Add(newRecord); db.StripeCustomers.Remove(cust); db.SaveChanges(); } }); return RedirectToAction("Index", "Home"); }
/// <summary> /// Changes the given subscription to use the new plan /// </summary> /// <param name="subscription"></param> /// <param name="newPlan"></param> public static void ChangeSubscriptionPlan(IStripeUser user, IStripeSubscription subscription, IStripeSubscriptionPlan newPlan) { StripeSubscriptionUpdateOptions options = new StripeSubscriptionUpdateOptions() { PlanId = newPlan.PaymentSystemId }; var subscriptionService = new StripeSubscriptionService(); subscriptionService.Update(user.PaymentSystemId, subscription.PaymentSystemId, options); System.Diagnostics.Trace.TraceInformation("Changed subscription for customer in stripe: '{0}' with new subscription id '{1}", user.Email, subscription.PaymentSystemId); }
public virtual StripeSubscription Update(string customerId, string subscriptionId, StripeSubscriptionUpdateOptions updateOptions) { var url = string.Format(Urls.Subscriptions + "/{1}", customerId, subscriptionId); url = ParameterBuilder.ApplyAllParameters(updateOptions, url); var response = Requestor.PostString(url, ApiKey); return(Mapper.MapFromJson <StripeSubscription>(response)); }
/// <summary> /// Updates the subscription tax. /// </summary> /// <param name="customerId">The customer identifier.</param> /// <param name="subStripeId">The sub stripe identifier.</param> /// <param name="taxPercent">The tax percent.</param> /// <returns></returns> public bool UpdateSubscriptionTax(string customerId, string subStripeId, decimal taxPercent = 0) { var result = true; try { var myUpdatedSubscription = new StripeSubscriptionUpdateOptions { TaxPercent = taxPercent }; _subscriptionService.Update(customerId, subStripeId, myUpdatedSubscription); } catch (Exception ex) { // TODO: log result = false; } return result; }
/// <summary> /// Updates the subscription. (Change subscription plan) /// </summary> /// <param name="customerId">The customer identifier.</param> /// <param name="subStripeId">The sub stripe identifier.</param> /// <param name="newPlanId">The new plan identifier.</param> /// <param name="proRate">if set to <c>true</c> [pro rate].</param> /// <returns></returns> public bool UpdateSubscription(string customerId, string subStripeId, string newPlanId, bool proRate) { var result = true; try { var currentSubscription = this._subscriptionService.Get(customerId, subStripeId); var myUpdatedSubscription = new StripeSubscriptionUpdateOptions { PlanId = newPlanId, Prorate = proRate }; if (currentSubscription.TrialEnd != null && currentSubscription.TrialEnd > DateTime.UtcNow) { myUpdatedSubscription.TrialEnd = currentSubscription.TrialEnd; // Keep the same trial window as initially created. } _subscriptionService.Update(customerId, subStripeId, myUpdatedSubscription); } catch (Exception ex) { // TODO: Log result = false; } return result; }
public virtual async Task<StripeSubscription> UpdateAsync(string customerId, string subscriptionId, StripeSubscriptionUpdateOptions updateOptions, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) { var url = string.Format(Urls.Subscriptions + "/{1}", customerId, subscriptionId); return Mapper<StripeSubscription>.MapFromJson( await Requestor.PostStringAsync(this.ApplyAllParameters(updateOptions, url, false), SetupRequestOptions(requestOptions), cancellationToken) ); }
public string UpdateSubscription(string customerId, string subscriptionId, string planId) { try { var subscriptionUpdate = new StripeSubscriptionUpdateOptions(); subscriptionUpdate.PlanId = planId; StripeSubscription subscription = subService.Update(customerId, subscriptionId, subscriptionUpdate); return subscription.Id; } catch (Exception ex) { if (ex is StripeException) { StripeException exception = (StripeException)ex; StripeError err = exception.StripeError; return err.ErrorType; } return null; } }