Handled subscription deletion errors with logging

refs https://github.com/TryGhost/Ghost/issues/11557

If a subscription failed to delete, we would error and bailout of the
process, this updates it to log the error so that site owners have a
record of the error in the logs, but also to continue through the rest
of the subscriptions.
This commit is contained in:
Fabien O'Carroll 2020-07-24 13:10:37 +02:00 committed by Fabien 'egg' O'Carroll
parent b435d6a8c1
commit d63484e99a

View File

@ -266,8 +266,13 @@ module.exports = class StripePaymentProcessor {
});
for (const subscription of activeSubscriptions) {
const updatedSubscription = await del(this._stripe, 'subscriptions', subscription.id);
await this._updateSubscription(updatedSubscription);
try {
const updatedSubscription = await del(this._stripe, 'subscriptions', subscription.id);
await this._updateSubscription(updatedSubscription);
} catch (err) {
this.logging.error(`There was an error cancelling subscription ${subscription.id}`);
this.logging.error(err);
}
}
return true;