mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +03:00
Added paid subscription cancel email alert
refs TryGhost/Team#1826 - triggers paid subscription cancellation alert for staff users - passes tier and subscription information for the email - loads tier info from DB for the subscription tier
This commit is contained in:
parent
216eeb9d71
commit
4ac1a2c21e
@ -1203,6 +1203,22 @@ module.exports = class MemberRepository {
|
||||
member_id: member.id,
|
||||
from_plan: subscriptionModel.get('plan_id')
|
||||
}, sharedOptions);
|
||||
|
||||
if (this._labsService.isSet('emailAlerts')) {
|
||||
const subscriptionPriceData = _.get(updatedSubscription, 'items.data[0].price');
|
||||
let ghostProduct;
|
||||
try {
|
||||
ghostProduct = await this._productRepository.get({stripe_product_id: subscriptionPriceData.product}, {...sharedOptions, forUpdate: true});
|
||||
} catch (e) {
|
||||
ghostProduct = null;
|
||||
}
|
||||
await this.staffService.notifyPaidSubscriptionCancel({
|
||||
member: member.toJSON(),
|
||||
subscription: updatedSubscription,
|
||||
cancellationReason: data.subscription.cancellationReason,
|
||||
tier: ghostProduct?.toJSON()
|
||||
});
|
||||
}
|
||||
} else {
|
||||
updatedSubscription = await this._stripeAPIService.continueSubscriptionAtPeriodEnd(
|
||||
data.subscription.subscription_id
|
||||
|
Loading…
Reference in New Issue
Block a user