1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

cancel/uncancel sub

This commit is contained in:
Kyle Spearrin
2017-04-10 16:43:24 -04:00
parent 4209d91c43
commit 80ca89b3f6
3 changed files with 45 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
angular angular
.module('bit.organization') .module('bit.organization')
.controller('organizationBillingController', function ($scope, apiService, $state, $uibModal) { .controller('organizationBillingController', function ($scope, apiService, $state, $uibModal, toastr) {
$scope.charges = []; $scope.charges = [];
$scope.paymentSource = null; $scope.paymentSource = null;
$scope.plan = null; $scope.plan = null;
@@ -47,7 +47,28 @@
}; };
$scope.cancel = function () { $scope.cancel = function () {
if (!confirm('Are you sure you want to cancel? All users will lose access to the organization ' +
'at the end of this billing cycle.')) {
return;
}
apiService.organizations.putCancel({ id: $state.params.orgId }, {})
.$promise.then(function (response) {
toastr.success('Organization subscription has been canceled.');
load();
});
};
$scope.uncancel = function () {
if (!confirm('Are you sure you want to remove the cancellation request?')) {
return;
}
apiService.organizations.putUncancel({ id: $state.params.orgId }, {})
.$promise.then(function (response) {
toastr.success('Organization cancellation request has been removed.');
load();
});
}; };
function load() { function load() {
@@ -65,14 +86,16 @@
if (org.Subscription) { if (org.Subscription) {
$scope.subscription = { $scope.subscription = {
trialEndDate: org.Subscription.TrialEndDate, trialEndDate: org.Subscription.TrialEndDate,
cancelNext: org.Subscription.CancelAtNextBillDate, cancelledDate: org.Subscription.CancelledDate,
status: org.Subscription.Status status: org.Subscription.Status,
cancelled: org.Subscription.Status === 'cancelled',
markedForCancel: org.Subscription.Status === 'active' && org.Subscription.CancelledDate
}; };
} }
$scope.nextBill = null; $scope.nextInvoice = null;
if (org.UpcomingInvoice) { if (org.UpcomingInvoice) {
$scope.nextBill = { $scope.nextInvoice = {
date: org.UpcomingInvoice.Date, date: org.UpcomingInvoice.Date,
amount: org.UpcomingInvoice.Amount amount: org.UpcomingInvoice.Amount
}; };
@@ -109,7 +132,8 @@
failureMessage: org.Charges[i].FailureMessage, failureMessage: org.Charges[i].FailureMessage,
refunded: org.Charges[i].Refunded, refunded: org.Charges[i].Refunded,
partiallyRefunded: org.Charges[i].PartiallyRefunded, partiallyRefunded: org.Charges[i].PartiallyRefunded,
refundedAmount: org.Charges[i].RefundedAmount refundedAmount: org.Charges[i].RefundedAmount,
invoiceId: org.Charges[i].InvoiceId
}); });
} }
$scope.charges = charges; $scope.charges = charges;

View File

@@ -10,6 +10,12 @@
<h3 class="box-title">Plan</h3> <h3 class="box-title">Plan</h3>
</div> </div>
<div class="box-body"> <div class="box-body">
<div class="alert alert-warning" ng-if="subscription && subscription.cancelled">
The subscription to this organization has been canceled.
</div>
<div class="alert alert-warning" ng-if="subscription && subscription.markedForCancel">
The subscription to this organization has been marked for cancellation at the end of the current billing period.
</div>
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<dl> <dl>
@@ -22,9 +28,9 @@
<div class="col-sm-6"> <div class="col-sm-6">
<dl> <dl>
<dt>Status</dt> <dt>Status</dt>
<dd style="text-transform: capitalize;">{{subscription.status || '-'}}</dd> <dd style="text-transform: capitalize;">{{(subscription && subscription.status) || '-'}}</dd>
<dt>Next Charge</dt> <dt>Next Charge</dt>
<dd>{{nextBill ? ((nextBill.date | date: format: mediumDate) + ', ' + (nextBill.amount | currency:'$')) : '-'}}</dd> <dd>{{nextInvoice ? ((nextInvoice.date | date: format: mediumDate) + ', ' + (nextInvoice.amount | currency:'$')) : '-'}}</dd>
</dl> </dl>
</div> </div>
</div> </div>
@@ -54,9 +60,14 @@
<button type="button" class="btn btn-default btn-flat" ng-click="changePlan()"> <button type="button" class="btn btn-default btn-flat" ng-click="changePlan()">
Change Plan Change Plan
</button> </button>
<button type="button" class="btn btn-default btn-flat" ng-click="cancel()" ng-if="!noSubscription"> <button type="button" class="btn btn-default btn-flat" ng-click="cancel()"
ng-if="!noSubscription && !subscription.cancelled && !subscription.markedForCancel">
Cancel Plan Cancel Plan
</button> </button>
<button type="button" class="btn btn-default btn-flat" ng-click="uncancel()"
ng-if="!noSubscription && subscription.markedForCancel">
Uncancel Plan
</button>
</div> </div>
</div> </div>
<div class="box"> <div class="box">

View File

@@ -43,6 +43,7 @@
putSeat: { url: _apiUri + '/organizations/:id/seat', method: 'POST', params: { id: '@id' } }, putSeat: { url: _apiUri + '/organizations/:id/seat', method: 'POST', params: { id: '@id' } },
putUpgrade: { url: _apiUri + '/organizations/:id/upgrade', method: 'POST', params: { id: '@id' } }, putUpgrade: { url: _apiUri + '/organizations/:id/upgrade', method: 'POST', params: { id: '@id' } },
putCancel: { url: _apiUri + '/organizations/:id/cancel', method: 'POST', params: { id: '@id' } }, putCancel: { url: _apiUri + '/organizations/:id/cancel', method: 'POST', params: { id: '@id' } },
putUncancel: { url: _apiUri + '/organizations/:id/uncancel', method: 'POST', params: { id: '@id' } },
del: { url: _apiUri + '/organizations/:id/delete', method: 'POST', params: { id: '@id' } } del: { url: _apiUri + '/organizations/:id/delete', method: 'POST', params: { id: '@id' } }
}); });