1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00

Updated billing to cancel at end of billing

This commit is contained in:
Uncled1023 2021-11-28 20:57:15 -08:00
parent a82f3bd56d
commit 481360b831
4 changed files with 27 additions and 13 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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>

View File

@ -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 });