mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 10:53:34 +03:00
2edb7226e1
refs https://github.com/TryGhost/Ghost/issues/12256, https://github.com/TryGhost/Ghost/issues/12255 Currently when listing subscriptions for Members in both the Admin and the Theme, we only show the subscriptions which have a status of trialing or active. Based on discussion, the `unpaid` and `past_due` states on Stripe also represent owner's intention of considering a subscription as active instead of `cancelled`, so we allow any subscriptions under these 2 states to be also listed for a member and consider them as `paid`. This updates Admin to consider those subscriptions as active as well. - Subscriptions will go into a past_due state if the payment is missed, this should be considered a grace period where the member still has access. - After this the subscriptions will either go to the unpaid or the cancelled state - this can be configured on an account by account basis in the Stripe dashboard. `unpaid` is considered as an intention to keep the subscription to allow for re-activation later.
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
import ModalComponent from 'ghost-admin/components/modal-base';
|
|
import {alias} from '@ember/object/computed';
|
|
import {computed} from '@ember/object';
|
|
import {reads} from '@ember/object/computed';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency';
|
|
|
|
export default ModalComponent.extend({
|
|
membersStats: service(),
|
|
|
|
shouldCancelSubscriptions: false,
|
|
|
|
// Allowed actions
|
|
confirm: () => {},
|
|
|
|
member: alias('model'),
|
|
|
|
cancelSubscriptions: reads('shouldCancelSubscriptions'),
|
|
|
|
hasActiveStripeSubscriptions: computed('member', function () {
|
|
let subscriptions = this.member.get('stripe');
|
|
|
|
if (!subscriptions || subscriptions.length === 0) {
|
|
return false;
|
|
}
|
|
|
|
let firstActiveStripeSubscription = subscriptions.find((subscription) => {
|
|
return ['active', 'trialing', 'unpaid', 'past_due'].includes(subscription.status);
|
|
});
|
|
|
|
return firstActiveStripeSubscription !== undefined;
|
|
}),
|
|
|
|
actions: {
|
|
confirm() {
|
|
this.deleteMember.perform();
|
|
},
|
|
|
|
toggleShouldCancelSubscriptions() {
|
|
this.set('shouldCancelSubscriptions', !this.shouldCancelSubscriptions);
|
|
}
|
|
},
|
|
|
|
deleteMember: task(function* () {
|
|
try {
|
|
yield this.confirm(this.shouldCancelSubscriptions);
|
|
this.membersStats.invalidate();
|
|
} finally {
|
|
this.send('closeModal');
|
|
}
|
|
}).drop()
|
|
});
|