Browse Source

Updated billing to cancel at end of billing

master
Teknikode 7 months ago
parent
commit
481360b831
  1. 2
      BillingCore/BillingService.cs
  2. 28
      BillingCore/StripeService.cs
  3. 8
      Teknik/Areas/TOS/Views/TOS/Index.cshtml
  4. 2
      Teknik/Areas/User/Controllers/UserController.cs

2
BillingCore/BillingService.cs

@ -32,7 +32,7 @@ namespace Teknik.BillingCore @@ -32,7 +32,7 @@ namespace Teknik.BillingCore
public abstract Subscription GetSubscription(string subscriptionId);
public abstract Subscription CreateSubscription(string customerId, string priceId);
public abstract Subscription EditSubscriptionPrice(string subscriptionId, string priceId);
public abstract bool CancelSubscription(string subscriptionId);
public abstract bool CancelSubscription(string subscriptionId, bool atEndOfPeriod);
public abstract CheckoutSession CreateCheckoutSession(string customerId, string priceId, string successUrl, string cancelUrl);
public abstract CheckoutSession GetCheckoutSession(string sessionId);

28
BillingCore/StripeService.cs

@ -230,17 +230,31 @@ namespace Teknik.BillingCore @@ -230,17 +230,31 @@ namespace Teknik.BillingCore
return null;
}
public override bool CancelSubscription(string subscriptionId)
public override bool CancelSubscription(string subscriptionId, bool atEndOfperiod)
{
if (!string.IsNullOrEmpty(subscriptionId))
{
var cancelOptions = new SubscriptionCancelOptions()
if (atEndOfperiod)
{
InvoiceNow = true
};
var subscriptionService = new SubscriptionService();
var subscription = subscriptionService.Cancel(subscriptionId, cancelOptions);
return subscription.Status == "canceled";
var cancelOptions = new SubscriptionUpdateOptions()
{
CancelAtPeriodEnd = true
};
var subscriptionService = new SubscriptionService();
var subscription = subscriptionService.Update(subscriptionId, cancelOptions);
return subscription.CancelAtPeriodEnd;
}
else
{
var cancelOptions = new SubscriptionCancelOptions()
{
InvoiceNow = true
};
var subscriptionService = new SubscriptionService();
var subscription = subscriptionService.Cancel(subscriptionId, cancelOptions);
return subscription.Status == "canceled";
}
}
return false;
}

8
Teknik/Areas/TOS/Views/TOS/Index.cshtml

@ -27,13 +27,13 @@ @@ -27,13 +27,13 @@
<li>Subscription benifits may change at any time</li>
<li>Any benifits applied to an account will stay for the lifetime of the subscription</li>
</ul>
<h3>Refund Policy</h3>
<h3>Cancellation Policy</h3>
<ul>
<li>You may recieve a full refund within 10 days of purchase</li>
<li>You may only request a refund once per account</li>
<li>You may cancel your subscriptions at any time</li>
<li>When you cancel a subscription, the subscription will still be active until the end of the billing period. You can renew a subscription until the billing period ends.</li>
<li>The price for a subscription can change at any time. You will not recieve a refund for the change in price</li>
<li>If the account is terminated for breaching the Terms of Service, no refund will be available</li>
<li>If a refund is given, all benifits for an account will be removed to match the current Free Account level</li>
<li>Once a subscription is canceled, all benifits for an account will be removed to match the current Free Account level</li>
</ul>
<h3>Email</h3>
<ul>

2
Teknik/Areas/User/Controllers/UserController.cs

@ -1515,7 +1515,7 @@ namespace Teknik.Areas.Users.Controllers @@ -1515,7 +1515,7 @@ namespace Teknik.Areas.Users.Controllers
if (product == null)
return Json(new { error = "Product does not exist" });
var result = billingService.CancelSubscription(subscriptionId);
var result = billingService.CancelSubscription(subscriptionId, true);
if (result)
return Json(new { result = true });

Loading…
Cancel
Save