public ActionResult <Subscription> CancelSubscription([FromBody] CancelSubscriptionRequest req) { var service = new SubscriptionService(); var subscription = service.Cancel(req.Subscription, null); return(subscription); }
public static TransactionResult StopSubscription(TransactionRequest request, StripeSettings stripeSettings, ILogger logger) { var subscriptionId = request.GetParameterAs <string>("subscriptionId"); InitStripe(stripeSettings, true); var subscriptionService = new SubscriptionService(); var subscription = subscriptionService.Cancel(subscriptionId, new SubscriptionCancelOptions()); var stopResult = new TransactionResult() { TransactionGuid = Guid.NewGuid().ToString(), ResponseParameters = new Dictionary <string, object>() { { "canceledAt", subscription.CanceledAt }, }, OrderGuid = request.Order.Guid, TransactionCurrencyCode = request.Order.CurrencyCode, }; if (subscription.Status == "canceled") { stopResult.Success = true; stopResult.NewStatus = PaymentStatus.Complete; return(stopResult); } else { logger.Log <TransactionResult>(LogLevel.Warning, "The subscription cancellation request for Order#" + stopResult.Order.Id + " by stripe failed." + subscription.StripeResponse.Content); stopResult.Success = false; stopResult.Exception = new Exception("An error occurred while processing refund"); return(stopResult); } }
public ActionResult <Subscription> CancelSubscription([FromBody] string Subscription) { var service = new SubscriptionService(); var subscription = service.Cancel(Subscription, null); return(subscription); }
public ActionResult Cancel() { try { StripeConfiguration.ApiKey = key; StripeConfiguration.MaxNetworkRetries = 2; var service = new SubscriptionService(); var cancelOptions = new SubscriptionCancelOptions { InvoiceNow = false, Prorate = false, }; Subscription subscription = service.Cancel(subscriptionId, cancelOptions); return(View("OrderStatus")); } catch (StripeException e) { var x = new { status = "Failed", message = e.Message }; return(this.Json(x)); } }
public Subscription CancelSubscription(string stripeSubscriptionId) { var subscriptionService = new SubscriptionService(); return(subscriptionService.Cancel(stripeSubscriptionId, new SubscriptionCancelOptions { InvoiceNow = true })); }
public ActionResult CancelSubscription(string subscriptinId) { var service = new SubscriptionService(); var subscription = service.Cancel(subscriptinId, null); this._mySubscriptionRepo.CancelSubscription(subscriptinId); return(RedirectToAction("Index")); }
public override async Task <ApiResult> RefundPaymentAsync(PaymentProviderContext <StripeCheckoutSettings> ctx) { try { // We can only refund a captured charge, so make sure we have one // otherwise there is nothing we can do var chargeId = ctx.Order.Properties["stripeChargeId"]; if (string.IsNullOrWhiteSpace(chargeId)) { return(null); } var secretKey = ctx.Settings.TestMode ? ctx.Settings.TestSecretKey : ctx.Settings.LiveSecretKey; ConfigureStripe(secretKey); var refundService = new RefundService(); var refundCreateOptions = new RefundCreateOptions() { Charge = chargeId }; var refund = refundService.Create(refundCreateOptions); var charge = refund.Charge ?? await new ChargeService().GetAsync(refund.ChargeId); // If we have a subscription then we'll cancel it as refunding an ctx.Order // should effecitvely undo any purchase if (!string.IsNullOrWhiteSpace(ctx.Order.Properties["stripeSubscriptionId"])) { var subscriptionService = new SubscriptionService(); var subscription = await subscriptionService.GetAsync(ctx.Order.Properties["stripeSubscriptionId"]); if (subscription != null) { subscriptionService.Cancel(ctx.Order.Properties["stripeSubscriptionId"], new SubscriptionCancelOptions { InvoiceNow = false, Prorate = false }); } } return(new ApiResult() { TransactionInfo = new TransactionInfoUpdate() { TransactionId = GetTransactionId(charge), PaymentStatus = GetPaymentStatus(charge) } }); } catch (Exception ex) { _logger.Error(ex, "Stripe - RefundPayment"); } return(ApiResult.Empty); }
public override ApiResult RefundPayment(OrderReadOnly order, StripeCheckoutSettings settings) { try { // We can only refund a captured charge, so make sure we have one // otherwise there is nothing we can do var chargeId = order.Properties["stripeChargeId"]; if (string.IsNullOrWhiteSpace(chargeId)) { return(null); } var secretKey = settings.TestMode ? settings.TestSecretKey : settings.LiveSecretKey; ConfigureStripe(secretKey); var refundService = new RefundService(); var refundCreateOptions = new RefundCreateOptions() { Charge = chargeId }; var refund = refundService.Create(refundCreateOptions); var charge = refund.Charge ?? new ChargeService().Get(refund.ChargeId); // If we have a subscription then we'll cancel it as refunding an order // should effecitvely undo any purchase if (!string.IsNullOrWhiteSpace(order.Properties["stripeSubscriptionId"])) { var subscriptionService = new SubscriptionService(); var subscription = subscriptionService.Get(order.Properties["stripeSubscriptionId"]); if (subscription != null) { subscriptionService.Cancel(order.Properties["stripeSubscriptionId"], new SubscriptionCancelOptions { InvoiceNow = false, Prorate = false }); } } return(new ApiResult() { TransactionInfo = new TransactionInfoUpdate() { TransactionId = GetTransactionId(charge), PaymentStatus = GetPaymentStatus(charge) } }); } catch (Exception ex) { Vendr.Log.Error <StripeCheckoutOneTimePaymentProvider>(ex, "Stripe - RefundPayment"); } return(ApiResult.Empty); }
public async Task <IActionResult> CancelSubscription([FromBody] CancelSubscriptionRequest req) { var service = new SubscriptionService(); var subscription = service.Cancel(req.Subscription, null); return(Ok(new ResponseViewModel <Subscription> { Data = subscription, Message = StripeConstants.CancelSubscription })); }
private Stripe.Subscription CancelStripeSubscription(string subscriptionId) { StripeConfiguration.ApiKey = _appKeys.StripeApiKey; SubscriptionCancelOptions options = new SubscriptionCancelOptions(); var service = new SubscriptionService(); var subscription = service.Cancel(subscriptionId, options); return(subscription); }
public IActionResult Cancel(string id) { ViewBag.isLoggedIn = HttpContext.Session.GetInt32("isLoggedIn"); if (ViewBag.isLoggedIn != 1) { return(RedirectToAction(nameof(Login))); } StripeConfiguration.SetApiKey(_stripeSettings.Value.SecretKey); var service = new SubscriptionService(); var subscription = service.Cancel(id, null); return(RedirectToAction(nameof(Index))); }
public void CancelSubscription(StripeChargeRequest req) { var info = GetByBusinessId(req.BusinessId); var service = new SubscriptionService(); Subscription subscription = service.Cancel(info.StripeSubscriptionId, null); dataProvider.ExecuteNonQuery( "Subscriptions_Cancel", (parameters) => { parameters.AddWithValue("@BusinessId", req.BusinessId); } ); }
public static async Task PerformAsync(ShardedCommandContext context, DataBase db) { var guild = FindOrCreateGuild.Perform(context.Guild, db); if (EnsureActiveSubscription.Perform(guild, db)) { var service = new SubscriptionService(); var options = new SubscriptionCancelOptions { Prorate = false }; service.Cancel(guild.SubscriptionId, options); await context.Channel.SendMessageAsync(text : "Your subscription has been canceled. Use `!volt pro` to re-upgrade at any time!"); } else { await context.Channel.SendMessageAsync(text : "You do not currently have an active Voltaire Pro subscription. To create one, use the" + " `!volt pro` command."); } }
public Subscription Cancel(string customerId, string subscriptionId, bool cancelAtPeriodEnd = false) { return(_stripeSubscriptionService.Cancel(subscriptionId, new SubscriptionCancelOptions { })); }
public string Cancel() { if (!HasPermissions()) { return(""); } var user = Query.Users.GetInfo(User.userId); var customerId = user.stripeCustomerId ?? ""; if (customerId != "") { //check if user has a subscription var subscriptionInfo = Query.Subscriptions.GetByOwner(User.userId); if (subscriptionInfo != null) { try { //get customer subscription var service = new SubscriptionService(); Subscription subscription = service.List(new SubscriptionListOptions() { CustomerId = customerId }).FirstOrDefault(); if ((DateTime.Now - subscriptionInfo.datestarted).TotalDays < 5) { //subscription is less than 5 days old, check if user started a campaign var startedCampaign = false; //TODO: Check if user started campaign if (startedCampaign == false) { //cancel subscription with full refund service.Cancel(subscription.Id, new SubscriptionCancelOptions() { Prorate = false }); //TODO: Get payment info from Stripe //TODO: Apply refund to payment in Stripe } else { //cancel subscription with partial refund service.Cancel(subscription.Id, new SubscriptionCancelOptions() { }); } } else { //cancel subscription with partial refund service.Cancel(subscription.Id, new SubscriptionCancelOptions() { }); } //update database Query.Subscriptions.Cancel(subscriptionInfo.subscriptionId, User.userId); } catch (Exception) { return(Error("Error canceling subscription")); } } } return(Success()); }
public Subscription CancelSub(string subId) { var subService = new SubscriptionService(); return(subService.Cancel(subId, null)); }